def test_check_update_error(self, doPackageLists, fs): doPackageLists.side_effect = Exception('Error!') with pytest.raises(XenAPIPlugin.Failure) as e: check_update(None, {}) doPackageLists.assert_called_once() assert e.value.params[0] == '-1' assert e.value.params[1] == 'Error!'
def test_ckeck_update_during_update(self, run_command, timeout, TimeoutException, fs): fs.create_file(pytest.plugins_lock_file, contents='update') run_command.return_value = {} timeout.return_value = 0 with mock.patch('fcntl.flock', wraps=mocked_flock_locked) as flock: with pytest.raises(XenAPIPlugin.Failure) as e: check_update(mock.MagicMock(), {}) flock.assert_called_once_with(mock.ANY, fcntl.LOCK_EX | fcntl.LOCK_NB) TimeoutException.assert_not_called() assert timeout.call_args_list == [((0, ), ), ()] assert e.value.params[0] == '-1' assert e.value.params[ 1] == 'The updater plugin is busy (current operation: update)'
def test_check_update(self, fs): expected = ' \ [{"name": "Dummy Package", "version": "0.0.0", "release": "Dummy released", \ "description": "Lorem ipsum...", "changelog": null, "url": "http://www.example.com/", "size": "0", \ "license": "GPLv2 and LGPLv2+ and BSD"}]' res = check_update(None, {}) assert json.loads(expected) == json.loads(res)
def test_ckeck_update_during_update(self, run_command, fs): fs.create_file(pytest.plugins_lock_file, contents='update') run_command.return_value = {} expected = ' \ [{"name": "Dummy Package", "version": "0.0.0", "release": "Dummy released", \ "description": "Lorem ipsum...", "changelog": null, "url": "http://www.example.com/", "size": "0", \ "license": "GPLv2 and LGPLv2+ and BSD"}]' res = check_update(None, {}) assert json.loads(expected) == json.loads(res)
def check_for_updates_action(self): self.status_message("Checking for updates.. This will take a few moments..") if updater.check_update() is True: latest = updater.latest_version() self.status_message("New version available! (" + updater.latest_version() + ") OSCDL is out of date.") QMessageBox.warning(self, 'OSCDL is out of date', 'Please go to the GitHub page and obtain the latest release\n' 'Newest Version: ' + latest) else: self.status_message("OSCDL is up to date!") QMessageBox.information(self, 'OSCDL is up to date', 'You are running the latest version of OSCDL!\n')
def main(argv=[]): args = parser.get_parser() verbose = 1 if args.verbose: verbose = 2 if args.debug: verbose = 3 if verbose>2: log_level=logging.DEBUG elif verbose==2: log_level=logging.INFO elif verbose==1: log_level=logging.WARNING elif verbose<1: log_level=logging.ERROR logging.basicConfig(level=log_level, format="%(asctime)s %(levelname)s: %(message)s") if args.command == 'version': print cexbot.get_version() return True # make sure this is always above command parsing # print config config.first_run() if verbose == 3: print args if args.command == 'config': if args.list: return config.list() elif args.edit: return config.edit_config() elif args.testauth: return config.test_auth() elif args.name and args.value: v = config.set(args.name, args.value) return config.cprint(args.name) elif args.name: return config.cprint(args.name) logging.error('Invalid config option') return 1 elif args.command == 'update': return updater.check_update() # not implemented elif args.command == 'cleardata': return config.clear_userdata() ac = cexapi.CexAPI(config.get('cex.username'), config.get('cex.apikey'), config.get('cex.secret')) dbi = db.DbManager() cx = CexMethods(ac, dbi) if args.command == 'balance': print "Balance: %s BTC" % ac.get_balance() return True elif args.command == 'initdb': return dbi.initdb() elif args.command == 'getmarket': return ac.get_market() elif args.command == 'getprice': return ac.get_market_quote() elif args.command == 'order': amount = args.amount price = args.price r = ac.place_order(amount, price) logging.info("Ordered: %s" % r) elif args.command == 'updatequotes': logging.info('Running updatequotes') ticker_timer = timer.ReqTimer(2, cx.update_ticker) ticker_timer.start() elif args.command == 'buybalance': logging.info('Running buybalance') balance_timer = timer.ReqTimer(5, ac.buy_balance) balance_timer.start()
def main(argv=[]): args = parser.get_parser() verbose = 1 if args.verbose: verbose = 2 if args.debug: verbose = 3 if verbose>2: log_level=logging.DEBUG elif verbose==2: log_level=logging.INFO elif verbose==1: log_level=logging.WARNING elif verbose<1: log_level=logging.ERROR logging.basicConfig(level=log_level, format="%(asctime)s %(levelname)s: %(message)s") proxy = args.proxy proxy_host = args.proxy_host proxy_port = args.proxy_port proxy_type = args.proxy_type config.first_run() if args.command == 'version': print torsurvey.get_version() return True elif args.command == 'update': return updater.check_update() ac = torapi.TorAPI(proxy_host=proxy_host, proxy_port=proxy_port, proxy_type=proxy_type, timeout=args.timeout) dbi = db.DbManager(args.dbpath) dbi.init() tc = controller.TorController(ac, dbi) # cx = CexMethods(ac, dbi) if args.command == 'checkip': print "Checking IP address" print ac.get_ip() return True elif args.command == 'flushdb': dbi.flush() print "Cleared db" elif args.command == 'fetch': if not args.url: logging.error("URL to fetch from required") return False print "Fetching from %s " % args.url f = tc.fetch_sitelist(args.url, args.cache, (not args.noinsert)) return True elif args.command == 'read': if not args.filepath: logging.error("Need file to read onion addresses from") f = tc.read_sitelist(args.filepath, (not args.noinsert)) elif args.command == 'survey': tc.survey(args.deadonly) elif args.command == 'list': dbi.list()
# coding: utf-8 import sys import updater import xbmcgui update_status = updater.check_update() if update_status == '': import generator else: xbmcgui.Dialog().ok("[COLOR yellowgreen]B[/COLOR][COLOR dodgerblue]B[/COLOR][COLOR white]T[/COLOR][COLOR orangered]S[/COLOR]", update_status) sys.exit(-1) # xbmcgui.Dialog().ok("DEBUG", "[" + sys.argv[2] + "]") generator.go()
def main(): try: if conf.options.settings: backend.checking_pyqt() settings = gui.Settings() settings.show() settings.exec_() sys.exit(1) elif conf.LANGUAGE == conf.AUTO_STRING: backend.checking_pyqt() conf.LANGUAGE = conf.DEFAULTLANGUAGE settings = gui.Settings(tabs=_("Appearance"), fields=["language"], show_default_button=False, no_reboot=True) settings.show() if not settings.exec_(): sys.exit(0) if conf.options.dd: backend.checking_pyqt() from ufo_dd import DDWindow DDWindow.prepare(backend) creator = DDWindow(backend, conf.options.relaunch) creator.show() creator.exec_() sys.exit(1) if conf.options.update and conf.options.relaunch: updater.self_update(conf.options.update, conf.options.relaunch) elif not conf.NOUPDATE and not conf.options.respawn: updater.check_update(backend) logging.debug("Checking for running UFO processes") backend.check_process() backend.run() if conf.GUESTDEBUG: if gui.dialog_error_report( _("Debug mode"), _("%s was run in debug mode.\n" "You can help fixing your problem by submitting the debug reports" ) % (conf.PRODUCTNAME, ), _("Send debug reports"), error=False): report_files = glob.glob(conf.LOGFILE + "_*") report_files.insert(0, conf.LOGFILE) reports = "" for file in report_files: reports += "\n" + ("_" * len(file)) + "\n" + file + "\n\n" reports += open(file, 'r').read() params = urllib.urlencode({'report': reports}) try: urllib.urlopen(conf.REPORTURL, params) except: pass except Exception, e: import errno trace = traceback.format_exc() logging.debug(trace) if isinstance(e, OSError) and e.errno == errno.ECHILD: msg = _( "%s has encountered a minor error. Restarting the application may fix the problem." ) % (conf.PRODUCTNAME, ) error = False else: msg = _("%s has encountered a fatal error and will now be closed." ) % (conf.PRODUCTNAME, ) error = True if gui.dialog_error_report(_("Error"), msg + "\n\n" + \ _("You can help fixing this problem by submitting an error report"), _("Send a report"), trace, error=error): params = urllib.urlencode({'report': open(log_path, 'r').read()}) try: urllib.urlopen(conf.REPORTURL, params) except: pass try: shutil.copy( log_path, os.path.join(os.path.dirname(log_path), "last_log.log")) except: pass