def resume(self): logger.debug('resuming') if self.background_worker.is_alive(): raise RuntimeError('Resume called without first calling pause') self.background_worker = BackgroundWorker() self.background_worker.start()
def __init__(self): super().__init__() # settings self.app_name = "OSFOffline" self.app_author = "COS" # views self.start_screen = StartScreen() self.tray = SystemTray() self.preferences = Preferences() AlertHandler.setup_alerts(self.tray.tray_icon, self.tray.tray_alert_signal) # connect all signal-slot pairs self.setup_connections() self.background_worker = BackgroundWorker()
def start(self): logger.debug('Start in main called.') try: user = session.query(User).filter(User.logged_in).one() except MultipleResultsFound: session.query(User).delete() self.login_signal.emit() return except NoResultFound: self.login_signal.emit() return try: # Simple request to ensure user logged in with valid oauth_token user = asyncio.get_event_loop().run_until_complete( AuthClient().populate_user_data(user)) except AuthError as e: logging.exception(e.message) self.login_signal.emit() containing_folder = os.path.dirname(user.osf_local_folder_path) while not validate_containing_folder(containing_folder): logger.warning( 'Invalid containing folder: {}'.format(containing_folder)) AlertHandler.warn( 'Invalid containing folder. Please choose another.') containing_folder = os.path.abspath( self.set_containing_folder_initial()) user.osf_local_folder_path = os.path.join(containing_folder, 'OSF') save(session, user) self.tray.set_containing_folder(containing_folder) if not os.path.isdir(user.osf_local_folder_path): os.makedirs(user.osf_local_folder_path) self.start_tray_signal.emit() logger.debug('starting background worker from main.start') self.background_worker = BackgroundWorker() self.background_worker.start()