def buildDriver(self, accountName: str, side: str, reuse: bool = False) -> None: """Build the driver object in the worker from this account side.""" if reuse is True and self.driver is not None: return None self.driver = None # Build the driver. account = loadAccount(accountName) repository = account.fw_getSide(side) driver = repository.fw_getDriver() self.repositoryName = repository.getClassName() #TODO: move to a debug controller. runtime.ui.debugC(DRV, "built driver '{}' for '{}'", driver.getClassName(), driver.getRepositoryName()) runtime.ui.debugC(DRV, "'{}' has conf {}", repository.getClassName(), driver.conf) self.driver = driver return driver
def run(self, taskQueue: Queue) -> None: """Sequentially process the accounts.""" # # Loop over the available account names. # for accountName in Channel(taskQueue): # The syncer let explode errors it can't recover from. try: self.processing(accountName) # Get the account instance from the rascal. account = loadAccount(accountName) self._syncAccount(account) # Wait until folders are done. self.setExitCode(0) #TODO: Here, we only keep max exit code. Would worth using the # rascal at the end of the process for each account. except Exception as e: runtime.ui.error("could not sync account %s" % accountName) runtime.ui.exception(e) #TODO: honor rascal! self.setExitCode(10) # See manual. self.checkExitCode() # Sanity check. self.referent.accountEngineDone(self.getExitCode())
def run(self, taskQueue: Queue) -> None: """Sequentially process the accounts.""" # # Loop over the available account names. # for accountName in Channel(taskQueue): # The syncer let explode errors it can't recover from. try: self.processing(accountName) # Get the account instance from the rascal. account = loadAccount(accountName) self._syncAccount(account) # Wait until folders are done. self.setExitCode(0) #TODO: Here, we only keep max exit code. Would worth using the # rascal at the end of the process for each account. except Exception as e: runtime.ui.error("could not sync account %s"% accountName) runtime.ui.exception(e) #TODO: honor rascal! self.setExitCode(10) # See manual. self.checkExitCode() # Sanity check. self.referent.accountEngineDone(self.getExitCode())
def syncAccounts(self, accountQueue: Queue): """Sequentially process the accounts.""" # # Loop over the available account names. # for accountName in Channel(accountQueue): self.processing(accountName) # Declare we starts to process an account. self.referent.running() # The syncer will let expode errors it can't recover from. try: # Get the account instance from the rascal. account = loadAccount(accountName) self._syncAccount(account) except Exception as e: runtime.ui.error("could not sync account %s"% accountName) runtime.ui.exception(e) #TODO: honor hook! self.setExitCode(10) # See manual. self.checkExitCode() self.referent.stop(self.getExitCode())
def run(self): cls_accounts = runtime.rascal.getAll([Account]) repositories = [] for cls_account in cls_accounts: account = loadAccount(cls_account) repositories.append(account.fw_getLeft()) repositories.append(account.fw_getRight()) for repository in repositories: if isinstance(repository, DriverInterface): continue try: repository.fw_addController(ExamineController) driver = repository.fw_getDriver() self.ui.info("# Repository %s (type %s)"% (repository.getClassName(), driver.getClassName())) self.ui.info("") self.ui.info("controllers: %s"% repository.controllers) self.ui.info("") driver.connect() driver.getFolders() self.ui.info("") except Exception as e: raise self.ui.warn("got %s %s"% (repr(e), str(e)))
def buildDriver(self, accountName: str, side: str, reuse: bool=False) -> None: """Build the driver object in the worker from this account side.""" if reuse is True and self.driver is not None: return None account = loadAccount(accountName) repository = account.fw_getSide(side) self._buildDriver(repository)
def buildDriver(self, accountName: str, side: str, reuse: bool = False) -> None: """Build the driver object in the worker from this account side.""" if reuse is True and self.driver is not None: return None account = loadAccount(accountName) repository = account.fw_getSide(side) self._buildDriver(repository)
def _syncFolder(self, folder: Folder): """Sync one folder.""" account = loadAccount(self.accountName) leftRepository = account.fw_getLeft() rightRepository = account.fw_getRight() self.left.buildDriver(self.accountName, 'left') self.rght.buildDriver(self.accountName, 'right') self.left.connect() self.rght.connect() self.left.select(folder) self.rght.select(folder)
def buildDriver(self, accountName: str, side: str, reuse: bool = False) -> None: """Build the driver object in the worker from this account side.""" if reuse is True and self.driver is not None: return None self._clear() # Build the driver. account = loadAccount(accountName) repository = account.fw_getSide(side) self.repositoryName = repository.getClassName() self.driver = repository.fw_getDriver() self._driverAccept() self._debugBuild() self._info("driver ready!")
def buildDriver(self, accountName: str, side: str, reuse: bool=False) -> None: if reuse is True and self._driver is not None: return None self._driver = None # Build the driver. account = loadAccount(accountName) repository = account.fw_getSide(side) driver = repository.fw_getDriver() #TODO: move to a debug controller. self.ui.debugC(DRV, "built driver '{}' for '{}'", driver.getClassName(), driver.getRepositoryName()) self.ui.debugC(DRV, "'{}' has conf {}", repository.getClassName(), driver.conf) self._driver = driver return driver
def run(self, taskQueue: Queue) -> None: """Sequentially process the accounts.""" # # Loop over the available account names. # for accountName in Channel(taskQueue): self.processing(accountName) # The syncer will let expode errors it can't recover from. try: # Get the account instance from the rascal. account = loadAccount(accountName) self._syncAccount(account) except Exception as e: runtime.ui.error("could not sync account %s"% accountName) runtime.ui.exception(e) #TODO: honor hook! self.setExitCode(10) # See manual. self.checkExitCode() self.referent.stop(self.getExitCode())
def run(self) -> None: class Report(object): def __init__(self): self._number = 0 self.content = {} def _getNumber(self): self._number += 1 return self._number def line(self, line: str = ''): self.content[self._getNumber()] = ('line', (line, )) def list(self, elements: list = []): self.content[self._getNumber()] = ('list', (elements, )) def title(self, title: str, level: int = 1): self.content[self._getNumber()] = ('title', (title, level)) def markdown(self): for lineDef in self.content.values(): kind, args = lineDef if kind == 'title': title, level = args prefix = '#' * level print("\n%s %s\n" % (prefix, title)) if kind == 'list': for elem in args[0]: print("* %s" % elem) if kind == 'line': print(args[0]) cls_accounts = runtime.rascal.getAll([Account]) repositories = [] for cls_account in cls_accounts: account = loadAccount(cls_account) repositories.append(account.fw_getLeft()) repositories.append(account.fw_getRight()) report = Report() for repository in repositories: if isinstance(repository, DriverInterface): continue try: repository.fw_insertController(ExamineController, {'report': report}) driver = repository.fw_getDriver() report.title( "Repository %s (driver %s)" % (repository.getClassName(), driver.getDriverClassName())) report.line("controllers: %s" % [x.__name__ for x in repository.controllers]) driver.connect() driver.getFolders() report = driver.fw_getReport() except Exception as e: raise self.ui.warn("got %s %s" % (repr(e), str(e))) report.markdown()
def test_00_loadAccount(self): account = loadAccount(self.DEF_ACCOUNT) runtime.ui.debugC(ARC, repr(account)) self.assertIsInstance(account, Account) self.__class__.account = account
def run(self) -> None: class Report(object): def __init__(self): self._number = 0 self.content = {} def _getNumber(self): self._number += 1 return self._number def line(self, line: str=''): self.content[self._getNumber()] = ('line', (line,)) def list(self, elements: list=[]): self.content[self._getNumber()] = ('list', (elements,)) def title(self, title: str, level: int=1): self.content[self._getNumber()] = ('title', (title, level)) def markdown(self): for lineDef in self.content.values(): kind, args = lineDef if kind == 'title': title, level = args prefix = '#' * level print("\n%s %s\n"% (prefix, title)) if kind == 'list': for elem in args[0]: print("* %s"% elem) if kind == 'line': print(args[0]) cls_accounts = runtime.rascal.getAll([Account]) repositories = [] for cls_account in cls_accounts: account = loadAccount(cls_account) repositories.append(account.fw_getLeft()) repositories.append(account.fw_getRight()) report = Report() for repository in repositories: if isinstance(repository, DriverInterface): continue try: repository.fw_insertController(ExamineController, {'report': report}) driver = repository.fw_getDriver() report.title("Repository %s (driver %s)"% (repository.getClassName(), driver.getDriverClassName())) report.line("controllers: %s"% [x.__name__ for x in repository.controllers]) driver.connect() driver.getFolders() report = driver.fw_getReport() except Exception as e: raise self.ui.warn("got %s %s"% (repr(e), str(e))) report.markdown()