Compare commits

..

No commits in common. "e458ecc0c14eb0375332fd9a41c980f5fdb370fa" and "f6ba365dbec4dd96fc27d9f5c74309faf822afa4" have entirely different histories.

6 changed files with 8 additions and 49 deletions

View File

@ -152,21 +152,6 @@ class AdgClient:
raise Exception("Failed to create deadock resolver", raise Exception("Failed to create deadock resolver",
res.stdout, res.args) res.stdout, res.args)
def create_resource_nest(self, name: str, child_nest_name: str, location: int, envelope: int, system: str = ""):
if not system:
system = self.system_name
res = self._run(["crn",
"-s", f"{system}",
"-n", f"{name}",
"-c", f"{child_nest_name}",
"-l", f"{location}",
"-e", f"{envelope}"])
if res.returncode > 0:
raise Exception("Failed to create resource nest",
res.stdout, res.args)
def _create_unique_database_name(self, prefix: str) -> str: def _create_unique_database_name(self, prefix: str) -> str:
MAX_ATTEMPTS = 100 MAX_ATTEMPTS = 100
databases = self.get_databases() databases = self.get_databases()

View File

@ -15,7 +15,6 @@ class Cache:
if name in self._cache: if name in self._cache:
return path.abspath(path.join(self.dir, self._cache[name])) return path.abspath(path.join(self.dir, self._cache[name]))
print(f"Trying to fetch driver: {name}")
try: try:
driver = fetch.get_driver_by_exact_name(name) driver = fetch.get_driver_by_exact_name(name)
file = fetch.download_driver(driver, self.dir) file = fetch.download_driver(driver, self.dir)

View File

@ -1,6 +1,5 @@
import requests import requests
from os import path from os import path
from adg_control import ADG_DIR
class DriverUrl: class DriverUrl:
@ -36,7 +35,7 @@ def get_driver_by_exact_name(name: str) -> DriverUrl:
try: try:
res = next(driver for driver in drivers if driver.name == name) res = next(driver for driver in drivers if driver.name == name)
except StopIteration: except StopIteration:
raise Exception("Driver not found", name) raise Exception("Driver not found")
return res return res
@ -99,8 +98,6 @@ def download_driver(driver: DriverUrl, dir: str):
for chunk in res.iter_content(chunk_size=128): for chunk in res.iter_content(chunk_size=128):
file.write(chunk) file.write(chunk)
return file_name
def read_credentials() -> (str, str): def read_credentials() -> (str, str):
token = "" token = ""

View File

@ -1,17 +1,14 @@
from adg_control import AdgClient, ADG_EXE, ADG_DIR from adg_control import AdgClient, ADG_EXE, ADG_DIR
from parser import Parser from parser import Parser
from cache import Cache from cache import Cache
from sys import argv
def main(): def main():
print(argv[1]) parser = Parser("./test")
parser = Parser(argv[1])
client = AdgClient(ADG_EXE, ADG_DIR) client = AdgClient(ADG_EXE, ADG_DIR)
cache = Cache() cache = Cache()
for command in parser.commands: for command in parser.commands:
print(command.type)
command.execute(client, cache) command.execute(client, cache)

View File

@ -10,8 +10,7 @@ class CommandType(StrEnum):
NORMAL = auto(), NORMAL = auto(),
NEWSYSTEM = auto(), NEWSYSTEM = auto(),
HOTEL = auto(), HOTEL = auto(),
DEADLOCK = auto(), DEADLOCK = auto()
RESOURCENEST = auto(),
class Command(): class Command():
@ -29,8 +28,6 @@ class Command():
self._init_hotel(**kwargs) self._init_hotel(**kwargs)
elif self.type == CommandType.DEADLOCK: elif self.type == CommandType.DEADLOCK:
self._init_deadlock(**kwargs) self._init_deadlock(**kwargs)
elif self.type == CommandType.RESOURCENEST:
self._init_resourcenest(**kwargs)
except KeyError as e: except KeyError as e:
raise Exception("Required argument not found!", e) raise Exception("Required argument not found!", e)
@ -46,8 +43,6 @@ class Command():
self._execute_hotel(client, cache) self._execute_hotel(client, cache)
case CommandType.DEADLOCK: case CommandType.DEADLOCK:
self._execute_deadlock(client, cache) self._execute_deadlock(client, cache)
case CommandType.RESOURCENEST:
self._execute_resourcenest(client, cache)
def _init_newdb(self, **kwargs): def _init_newdb(self, **kwargs):
self.name = kwargs["name"] self.name = kwargs["name"]
@ -104,15 +99,6 @@ class Command():
if "host_name" in kwargs: if "host_name" in kwargs:
self.host_name = kwargs["host_name"] self.host_name = kwargs["host_name"]
def _init_resourcenest(self, **kwargs):
print(kwargs)
self.name = kwargs["name"]
self.child_nest_name = kwargs["child_nest_name"]
self.location = kwargs["location"]
self.envelope = kwargs["envelope"]
if "system" in kwargs:
self.system = kwargs["system"]
def _execute_newdb(self, client: AdgClient, cache: Cache): def _execute_newdb(self, client: AdgClient, cache: Cache):
client.create_database(self.name) client.create_database(self.name)
@ -130,7 +116,6 @@ class Command():
else: else:
abs_path = cache.get(self.device) abs_path = cache.get(self.device)
package_path = ntpath.relpath(abs_path, start=ADG_DIR) package_path = ntpath.relpath(abs_path, start=ADG_DIR)
print(abs_path, package_path)
client.create_normal_resource( client.create_normal_resource(
self.name, self.name,
@ -164,15 +149,6 @@ class Command():
system=self.system if hasattr(self, "system") else "" system=self.system if hasattr(self, "system") else ""
) )
def _execute_resourcenest(self, client: AdgClient, cache: Cache):
client.create_resource_nest(
self.name,
self.child_nest_name,
self.location,
self.envelope,
system=self.system if hasattr(self, "system") else ""
)
class Parser(): class Parser():
def __init__(self, path: str): def __init__(self, path: str):

5
test Normal file
View File

@ -0,0 +1,5 @@
newdb;name=horsedb
newsystem;
normal;name=PlateOrient 1.1;location=0;envelope=1;device=HRB.PlateOrient
hotel;name=PlateHotel 1.1;location=100;envelope=1;rows=8;storage_type=random
deadlock;name = Deadlock Resolver 1.1;location=70;envelope=1