def load_info(self): """ Get deputy's information if the file is json formatted, else update the file and return the information. :return: """ if self.check_format(): deputies = Updater().get_list() self.info = deputies[self.json_index] else: u = Updater() u.update() return self.load_info()
def __init__(self, download_path, url, title=u"自动更新", kill_process_name="MyClient.exe"): QDialog.__init__(self) self.setupUi(self) self.setWindowTitle(title) self.download_path = os.path.join(download_path, "update") if not os.path.exists(self.download_path): os.mkdir(self.download_path) self.download_files = [] self.updater = Updater(url) self.kill_process_name = kill_process_name self.total_progressbar.setValue(0) self.total_progressbar.setMaximum(100) self.progressbar.setValue(0) self.progressbar.setMaximum(100) self.btn.clicked.connect(self.check_update) self.update_progressbar_signal.connect(self.on_update_progressbar) self.finish_update_signal.connect(self.on_finish_update)
def MainMenu(): oc = ObjectContainer(title2=TITLE, no_cache=True) Updater(PREFIX + '/update', oc) if not ValidateServer(): return MessageContainer( header=u'%s' % L('Error'), message=u'%s' % L('Please specify server address in plugin preferences')) items = GetItems() if not items: return NoContents() server = GetServerUrl() for item in items: if len(item['Files']) > 1: oc.add( DirectoryObject(key=Callback(List, hash=item['Hash']), title=u'%s' % item['Name'])) else: file = item['Files'][0] oc.add(GetVideoObject(server + file['Link'], file['Name'])) return oc
def updater_init(self): print("\nGenerating script...") self.us = Updater(self.is_64bit) if self.model != "Unknown": self.us.check_device(self.model, self.ext_models) self.us.blank_line() self.us.ui_print("Updating from %s" % self.verify_info[1]) self.us.ui_print("to %s" % self.verify_info[2]) self.us.ui_print("It may take several minutes, please be patient.") self.us.ui_print(" ") self.us.blank_line() self.us.ui_print("Remount /system ...") self.us.add("[ $(is_mounted /system) == 1 ] || umount /system") self.us.mount("/system") self.us.add("[ -f /system/build.prop ] || {", end="\n") self.us.ui_print(" ", space_no=2) self.us.abort("Failed to mount /system!", space_no=2) self.us.add("}") self.us.blank_line() if self.pt_flag: self.us.ui_print("Remount /vendor ...") self.us.add("[ $(is_mounted /vendor) == 1 ] || umount /vendor") self.us.mount("/vendor") self.us.blank_line() self.us.ui_print("Verify Rom Version ...") self.us.add( "[ $(file_getprop /system/build.prop %s) == \"%s\" ] || {" % (self.verify_info[0], self.verify_info[1]), end="\n") self.us.ui_print(" ", space_no=2) self.us.abort("Failed! Versions Mismatch!", space_no=2) self.us.add("}")
def testIncrementRemoteSetup(self): file = '/setup.py' pattern = "\s+version='(\d+\.\d+\.\d+)'," u = Updater(gittoken=self.gh_token, config=self.config, branch='develop', file=file, patterns=pattern, repo=self.repo) setup = u.get_file_from_git() version = u.get_version_from_string(pattern, setup) incremented = u.increment_version(version) newsetup = u.increment_version_in_content(setup) u.update_file(newsetup) brand_new_setup = u.get_file_from_git() newversion = u.get_version_from_string(pattern, brand_new_setup) self.assertEqual(newversion, incremented, "Version from Git matches expected value")
def main(): setup_logging(debug=settings.DEBUG) sources_collection = SourcesCollection(requested_sources=settings.SOURCES) logs_api_client = LogsApiClient(token=settings.TOKEN, host=settings.LOGS_API_HOST) logs_api_loader = Loader(client=logs_api_client, chunk_size=settings.REQUEST_CHUNK_ROWS, allow_cached=settings.ALLOW_CACHED) database = ClickhouseDatabase(url=settings.CH_HOST, login=settings.CH_USER, password=settings.CH_PASSWORD, db_name=settings.CH_DATABASE) db_controllers_collection = DbControllersCollection( db=database, sources_collection=sources_collection) state_storage = FileStateStorage(file_name=settings.STATE_FILE_PATH) updater = Updater(loader=logs_api_loader) scheduler = Scheduler( state_storage=state_storage, app_ids=settings.APP_IDS, update_interval=settings.UPDATE_INTERVAL, update_limit=settings.UPDATE_LIMIT, fresh_limit=settings.FRESH_LIMIT, scheduling_definition=sources_collection.scheduling_definition()) updates_controller = UpdatesController( scheduler=scheduler, updater=updater, sources_collection=sources_collection, db_controllers_collection=db_controllers_collection) try: updates_controller.run() except KeyboardInterrupt: logger.info('Interrupted') return
def brute_force(self, current_season): actual_scores = self.get_actual_scores(current_season) updater = Updater(current_season) updater.update_all(request_new=True) progress = 0 n = 25 best_accuracy = -1 best = None for form_diff_multiplier in np.linspace(0, 5, n): for home_advantage_multiplier in np.linspace(0, 30, n): predictor = Predictor(current_season, home_advantage_multiplier, form_diff_multiplier) accuracy, results_accuracy = self.score_predictions( predictor, actual_scores, updater.json_data, updater.data.team_names, updater.data.form, updater.data.home_advantages) if accuracy > best_accuracy: best_accuracy = accuracy best = ('form:', form_diff_multiplier, 'home advantage:', home_advantage_multiplier) print('New best found:', best) print(' Accuracy:', accuracy) print(' Results accuracy:', results_accuracy) print(round((progress / (n**2)) * 100, 2), '%') progress += 1 print('FINAL BEST:', best) print(' Accuracy:', best_accuracy)
def test_set_results(self): updater = Updater("localhost", 1337, TESTS) results = updater.set_results(TestStatus.RUNTIME_ERROR) self.assertEqual(len(results), 3, "There must be exactly three results") for i in range(1, 3): self.assertEqual(results[i]["score"], 0) self.assertEqual(results[i]["status"], TestStatus.RUNTIME_ERROR.name)
def MainMenu(): cats = Common.GetPage('/').xpath( '//div[@id="gkDropMain"]//a[contains(@href, ".html")]') if not cats: return MessageContainer(L('Error'), L('Service not avaliable')) oc = ObjectContainer(title2=L(Common.TITLE), no_cache=True) Updater(Common.PREFIX + '/update', oc) oc.add(DirectoryObject(key=Callback(ShowNews), title=u'Новые серии')) oc.add(DirectoryObject(key=Callback(ShowPopular), title=u'Популярное')) for cat in cats: title = cat.text_content() oc.add( DirectoryObject(key=Callback(ShowCategory, path=cat.get('href'), title=title), title=title)) oc.add( InputDirectoryObject(key=Callback(Search), title=u'Поиск', prompt=u'Искать на HDSerials')) oc.add(DirectoryObject(key=Callback(History), title=u'История')) return oc
def __check_for_updates(self): updater = Updater() updater.check_for_updates() if not updater.is_latest: response = QMessageBox.question(self.__main_widget, "Update Available!", "A New version of this tool is available, would you like to download it now?", (QMessageBox.Yes|QMessageBox.No), ) if response == QMessageBox.Yes: webbrowser.open(updater.latest_url)
def exec_helper(self, add_info, path_source, tests, run_config, expected_results): updater = Updater("fake/endpoint", 42, []) updater_results = [] add_info.side_effect = lambda result: updater_results.append(result) # Configure fake paths to the solution and its executable and compile it language = common.get_language_by_source_name(path_source) path_executable = os.path.join(config.PATH_SANDBOX, "solution.{}".format(common.get_executable_extension(language))) compilation_status = Compiler.compile( language=language, path_source=path_source, path_executable=path_executable ) self.assertEqual(compilation_status, "") run_config.executable_path = path_executable try: for test in tests: execute_problem(updater=updater, submit_id=42, result_id=0, test=test, run_config=run_config) except: self.fail("Failed during execution of tests.") self.assertEqual(add_info.call_count, len(tests) * 2) for result in updater_results: if result["status"] != TestStatus.TESTING.name: # print(result) found = False for i in range(len(expected_results)): if result["status"] == expected_results[i].name: found = True del expected_results[i] break self.assertTrue(found, msg="Status '{}' not among expected results.".format(result["status"]))
def MainMenu(complete=False, offline=False): oc = ObjectContainer(title2=TITLE, no_cache=True, replace_parent=False) if offline: ResetToken() if not CheckToken(): oc.add(DirectoryObject( key=Callback(Authorization), title=u'%s' % L('Authorize'), thumb=ICONS['options'], )) if complete: oc.header = L('Authorize') oc.message = L('You must enter code for continue') return oc Updater(PREFIX+'/update', oc) oc.add(DirectoryObject( key=Callback(MySubscriptions), title=u'%s' % L('My Subscriptions'), thumb=ICONS['subscriptions'], )) oc.add(DirectoryObject( key=Callback(Category, title=L('What to Watch')), title=u'%s' % L('What to Watch'), thumb=ICONS['whatToWhatch'], )) oc.add(DirectoryObject( key=Callback(Playlists, uid='me', title=L('Playlists')), title=u'%s' % L('Playlists'), thumb=ICONS['playlists'], )) oc.add(DirectoryObject( key=Callback(Categories, title=L('Categories'), c_type='video'), title=u'%s' % L('Categories'), thumb=ICONS['categories'], )) oc.add(DirectoryObject( key=Callback(Categories, title=L('Browse channels'), c_type='guide'), title=u'%s' % L('Browse channels'), thumb=ICONS['browseChannels'], )) oc.add(DirectoryObject( key=Callback(Channel, oid='me', title=L('My channel')), title=u'%s' % L('My channel'), thumb=ICONS['account'], )) FillChannelInfo(oc, 'me', ('watchLater', 'watchHistory', 'likes')) oc.add(InputDirectoryObject( key=Callback( Search, s_type='video', title=u'%s' % L('Search Video') ), title=u'%s' % L('Search'), prompt=u'%s' % L('Search Video'), thumb=ICONS['search'] )) return AddSubscriptions(oc, uid='me')
def updater__check_reinitialization(self, identifier): # # VARIABLES # from environment import Environment from updater import Updater # # CODE # # we need the environment environment_directory = 'environments/' environment = Environment(identifier) environment.read_environment_file("./" + environment_directory + identifier + ".xml") environment.initialize() # and we need to create an exogenous network environment.network.create_exogenous_network( environment.parameter.network_density) updater = Updater(identifier, environment) print "<<< BEFORE UPDATE" print updater print "<<< UPDATING " updater.do_update() print updater updater.reinitialize(identifier, environment) print "<<< AFTER REINITIALIZATION" print updater
def VideoMainMenu(): if not Dict['auth']: return BadAuthMessage() oc = ObjectContainer(title2=TITLE, no_cache=True) Updater(PREFIX_V + '/update', oc) oc.add( DirectoryObject(key=Callback(VideoListChannels, uid=Prefs['username']), title=u'%s' % L('My channels'))) oc.add( DirectoryObject(key=Callback(VideoListGroups, uid=Prefs['username']), title=u'%s' % L('My groups'))) oc.add( DirectoryObject(key=Callback(VideoListFriends, uid=Prefs['username']), title=u'%s' % L('My friends'))) oc.add( DirectoryObject(key=Callback(VideoListChannels), title=u'%s' % L('All channels'))) oc.add( DirectoryObject(key=Callback(VideoCatalogueGroups), title=u'%s' % L('Catalogue'))) oc.add( InputDirectoryObject(key=Callback(VideoSearch, title=u'%s' % L('Search Video')), title=u'%s' % L('Search'), prompt=u'%s' % L('Search Video'))) return AddVideoAlbums(oc, Prefs['username'])
def MainMenu(): menu = Common.ApiRequest('menu') if not menu: return MessageContainer(L('Error'), L('Service not avaliable')) oc = ObjectContainer(title2=L(Common.TITLE), no_cache=True) Updater(Common.PREFIX + '/update', oc) oc.add( DirectoryObject( key=Callback(Rubric, oid=menu['id']), title=u'Все рубрики', )) oc.add( DirectoryObject( key=Callback(Rubric, oid=Common.SB_ANNONCE, is_announce=True), title=u'Расписание', )) for item in menu['menu']: oc.add( DirectoryObject( key=Callback(Rubric, oid=item['id']), title=item['name'], )) return oc
def MainMenu(): """ Setup Main menu Free Cams', Free Cams by Age', Free Cams by Region, Free Cams by Status """ oc = ObjectContainer(title2=TITLE, art=R(ART), no_cache=True) Updater(PREFIX + '/updater', oc) for t in CAT_LIST: oc.add(DirectoryObject(key=Callback(SubList, title=t), title=t)) if Client.Product in DumbKeyboard.clients: DumbKeyboard(PREFIX, oc, Search, dktitle='Search', dkthumb=R('icon-search.png')) DumbKeyboard(PREFIX, oc, Hashtag, dktitle='#Hashtag', dkthumb=R('icon-search.png')) else: oc.add(InputDirectoryObject( key=Callback(Search), title='Search', summary='Search Chaturbate', prompt='Search for...', thumb=R('icon-search.png') )) oc.add(InputDirectoryObject( key=Callback(Hashtag), title='#Hashtag', summary='Hashtag Chaturbate', prompt='Search hashtag...', thumb=R('icon-search.png') )) return oc
def __init__(self, session, args=None): self.skin = AP_UpdateScreen.skin Screen.__init__(self, session) self._session = session self._hasChanged = False self.updater = Updater(session) self['key_red'] = StaticText(_('Start Update')) self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], { 'red': self.keyStartUpdate, 'cancel': self.close }, -2) self['info'] = Label() self['info'].setText( 'AirPlayer Enigma2 Plugin\nyou are on Version: %s\n' % config.plugins.airplayer.version.value) self.onLayoutFinish.append(self.setCustomTitle) self['changelog'] = Label() self['changelog'].setText('searching for updates...\n') link = self.updater.checkForUpdate('', 0) if link != '' and link != 'up to date': self['changelog'].setText('Update Available:\n\n' + self.updater.getChangeLog()) else: self['changelog'].setText( 'no Updates available you are \nup to date\n') self.onLayoutFinish.append(self.setCustomTitle)
def VideoMainMenu(): oc = ObjectContainer(title1=L('Title')) oc.add( DirectoryObject(key=Callback(SubMenu, title='Alle TV-Sendungen', url='pt-tv'), title='Alle TV-Sendungen')) oc.add( DirectoryObject(key=Callback(SubMenu, title='SRF 1', url='pr-srf-1'), title='SRF 1')) oc.add( DirectoryObject(key=Callback(SubMenu, title='SRF zwei', url='pr-srf-2'), title='SRF zwei')) oc.add( DirectoryObject(key=Callback(SubMenu, title='SRF info', url='pr-srf-info'), title='SRF info')) # Add Preferences to main menu. oc.add(PrefsObject(title=L('Preferences'))) # Show update item, if available try: Updater(PREFIX + '/updater', oc) except Exception as e: Log.Error(e) return oc
def VideoMainMenu(): if not Dict['token']: return BadAuthMessage() oc = ObjectContainer(title2=TITLE, no_cache=True) Updater(PREFIX_V + '/update', oc) oc.add( DirectoryObject(key=Callback(VideoListGroups, uid=Dict['user_id']), title=u'%s' % L('My groups'))) oc.add( DirectoryObject(key=Callback(VideoListFriends, uid=Dict['user_id']), title=u'%s' % L('My friends'))) oc.add( DirectoryObject(key=Callback(VideoListSubscriptions, uid=Dict['user_id']), title=u'%s' % L('My subscriptions'))) oc.add( InputDirectoryObject(key=Callback(Search, search_type='video', title=u'%s' % L('Search Video')), title=u'%s' % L('Search'), prompt=u'%s' % L('Search Video'))) return AddVideoAlbums(oc, Dict['user_id'])
def MainMenu(): """Setup Main Menu, Includes Updater""" oc = ObjectContainer(title2=TITLE, no_cache=True) mhref = '/movie' Updater(PREFIX + '/updater', oc) oc.add( DirectoryObject(key=Callback(DirectoryList, title='Most Recent', href='%s?sort=published' % mhref, page=1), title='Most Recent', thumb=R(ICON_RECENT))) oc.add( DirectoryObject(key=Callback(SortList, title='Most Viewed', href=mhref), title='Most Viewed', thumb=R(ICON_VIEWS))) oc.add( DirectoryObject(key=Callback(SortList, title='Top Rated', href=mhref), title='Top Rated', thumb=R(ICON_LIKE))) oc.add( DirectoryObject(key=Callback(CategoryList), title='Categories', thumb=R(ICON_CAT))) oc.add( DirectoryObject(key=Callback(SortListC, title='Pornstars', href='/pornstar'), title='Pornstars', thumb=R(ICON_STAR))) oc.add( DirectoryObject(key=Callback(MyBookmarks), title='My Bookmarks', thumb=R(ICON_BM))) if Client.Product in DumbPrefs.clients: DumbPrefs(PREFIX, oc, title='Preferences', thumb=R('icon-prefs.png')) else: oc.add(PrefsObject(title='Preferences', thumb=R('icon-prefs.png'))) if Client.Product in DumbKeyboard.clients: DumbKeyboard(PREFIX, oc, Search, dktitle='Search', dkthumb=R('icon-search.png')) else: oc.add( InputDirectoryObject(key=Callback(Search), title='Search', summary='Search JavHiHi', prompt='Search for...', thumb=R('icon-search.png'))) return oc
def handle_next(): json_index = int(request.args['json_index']) + 1 last = len(Updater().get_list()) - 1 if json_index == last: return redirect(url_for("main_page")) else: return redirect(url_for("record", json_index=json_index))
def test_discount_mask(self): updater = Updater(self.net, self.lr, entropy_const=self.entropy_const, value_const=self.value_const, gamma=self.gamma, _lambda=self._lambda) array = [1,1,1] mask = [0,1,0] expected_output = [1.99, 1, 1] output = updater.discount(array, mask, self.gamma) self.assertTrue(np.array_equal(expected_output, output))
def MusicMainMenu(): if not Dict['auth']: return BadAuthMessage() oc = ObjectContainer(title2=TITLE, no_cache=True) Updater(PREFIX_M + '/update', oc) oc.add( DirectoryObject(key=Callback(MusicListGroups, uid=Prefs['username']), title=u'%s' % L('My groups'))) oc.add( DirectoryObject(key=Callback(MusicListFriends, uid=Prefs['username']), title=u'%s' % L('My friends'))) oc.add( DirectoryObject(key=Callback(MusicList, uid=Prefs['username'], title=L('My music')), title=u'%s' % L('My music'))) oc.add( DirectoryObject(key=Callback(MusicRecomendations, uid=Prefs['username'], title=L('Recomendations')), title=u'%s' % L('Recomendations'))) oc.add( DirectoryObject(key=Callback(MusicCollections), title=u'%s' % L('Collections'))) oc.add( InputDirectoryObject(key=Callback(MusicSearch, title=u'%s' % L('Search Music')), title=u'%s' % L('Search'), prompt=u'%s' % L('Search Music'))) return oc
def runUpdate(self, projects=None, force=False): for pro in self.config["projects"]: try: if pro["hold"] and not force: continue except KeyError: pass try: pro["currentVersion"] except KeyError: pro.update({"currentVersion": ""}) if projects == None or pro["name"] in projects: try: pro_proxy = pro["proxy"] except KeyError: pro_proxy = self.config["requests"]["proxy"] obj = Updater(pro["name"], pro["path"], pro_proxy) new_version = obj.run(force, pro["currentVersion"]) if new_version: pro_index = self.config["projects"].index(pro) self.config["projects"][pro_index].update( {"currentVersion": new_version}) self.config.dumpconfig() try: for line in pro["post-cmds"]: line = line.replace("%PATH", '"%s"' % pro["path"]) line = line.replace("%NAME", pro["name"]) os.system(line) except KeyError: pass
def main_menu(): oc = ObjectContainer() oc.add( DirectoryObject(key=Callback(movies), title=L('movies'), summary=L('movies_desc'), thumb=R('play.png'))) oc.add( DirectoryObject(key=Callback(calendar), title=L('calendar'), summary=L('calendar_desc'), thumb=R('calendar.png'))) oc.add( DirectoryObject(key=Callback(queue), title=L('queue'), summary=L('queue_desc'), thumb=R('cloud.png'))) oc.add( DirectoryObject(key=Callback(history), title=L('history'), summary=L('history_desc'), thumb=R('history.png'))) oc.add( DirectoryObject(key=Callback(missing), title=L('missing'), summary=L('missing_desc'), thumb=R('exclamation-triangle.png'))) oc.add( DirectoryObject(key=Callback(cutoff), title=L('unmet'), summary=L('unmet_desc'), thumb=R('exclamation-triangle.png'))) oc.add(PrefsObject(title=L('settings'), thumb=R('cogs.png'))) Updater(PREFIX + '/updater', oc) return oc
def MainMenu(): oc = ObjectContainer(title2=TITLE, no_cache=True) Updater(PREFIX + '/update', oc) groups = GetGroups() if not groups: return NoContents() oc.add( InputDirectoryObject(key=Callback(Search), title=u'Поиск', prompt=u'Поиск канала')) oc.add( DirectoryObject(key=Callback(Search, query=' HD'), title=u'Каналы HD')) oc.add( DirectoryObject(key=Callback(Search, query=' 3D'), title=u'Каналы 3D')) for group in groups: oc.add( DirectoryObject(key=Callback(Group, group=group), title=u'%s' % group)) return oc
def run(self): try: if self._workload is None: print 'Assign workload before invoking run method - cannot proceed' self._logger.info( 'No workload assigned currently, please check your script') raise ValueError(expected_value='set of pipelines', actual_value=None) else: populator = Populator(workload=self._workload, pending_queue=self._pending_queue) populator.start_population() helper = Helper(pending_queue=self._pending_queue, executed_queue=self._executed_queue) helper.start_helper() updater = Updater(workload=self._workload, executed_queue=self._executed_queue) updater.start_update() pipe_count = len(self._workload) while pipe_count > 0: time.sleep(1) for pipe in self._workload: if pipe.completed: pipe_count -= 1 # Terminate threads self._logger.info('Closing populator thread') populator.terminate() self._logger.info('Populator thread closed') self._logger.info('Closing updater thread') updater.terminate() self._logger.info('Updater thread closed') self._logger.info('Closing helper thread') helper.terminate() self._logger.info('Helper thread closed') except Exception, ex: self._logger.error('Fatal error while running appmanager') # Terminate threads self._logger.info('Closing populator thread') populator.terminate() self._logger.info('Populator thread closed') self._logger.info('Closing updater thread') updater.terminate() self._logger.info('Updater thread closed') self._logger.info('Closing helper thread') helper.terminate() self._logger.info('Helper thread closed') raise UnknownError(text=ex)
def record(json_index): last = len(Updater().get_list()) - 1 if json_index < 0 or json_index > last: abort(404) return d = Deputy(json_index) current = d.info current['ljson_index'] = last return render_template('index.html', **current)
def test_mergeListToEntries(self): p, e = TestHelper.createPlan(self, "R") r = p.step_list entries = ParseText.planText_toEntries( load.loadText(join("material/test/test_update1.txt"))) u = Updater(r, entries) new_list = u.mergeListToEntries() self.assertEqual(r[0], new_list[0])
def start(self): self.processes = [ SystemCommand(self.sharedData), Updater(self.sharedData), Process(target=self.dumpSettings) ] for p in self.processes: p.start() self.manager.join()