def fetchandsavepage(links, username): database = Manager.getDatabaseInstance() crawler = Manager.getCrawlerInstance() database.getElseMakeUser(username) print("Database Made") #rdb.set_trace() links = json.loads(links) links = links['list'].values() for link in links: try: if not crawler: crawler = Manager.getCrawlerInstance() else: page = crawler.make_a_page(link['resolved_url']) page.get_page_contents() # need a method to generate tags tags = ["jvc", "pocket"] database.MakeWebPageNode(username, link['resolved_url'], page.title, page.content, tags) print("Hardware Done") print(page.url) #print self.page.content print(page.title) except: print("Exception occured") continue print("Fetching Articles code here")
def main(): waterTransport = WaterTransport(20, 36, 44.4) riverTram = RiverTram(34, 55, 33.4, "green") motorShip = MotorShip(55, 33, 22.5, "disel") manager = Manager([waterTransport, riverTram, motorShip]) print(manager.findForCapacity(34)) print(manager.findForMaxSpeed(33)) print(manager.sortByConsuptionv(False))
def setUp(self): self.manager = Manager() filepath = get_prism_model_dir() + get_sep() + "DPM.prism" self.manager.read_model_file(filepath) self.model = self.manager.model ltl = "true U<=10 failure" parsed_ltl = LTLParser().build_parser().parse_line(ltl) self.manager.set_manager_param_simple("duration", 10.0) self.checker = Checker(model=self.model, ltl=parsed_ltl, duration=10.0) self.manager.set_ltl(parsed_ltl) self.prism_x, self.prism_y = parse_csv_cols(get_prism_model_dir() + get_sep() + "Q_TRIGGER_1_20_1.csv")
def __init__(self, redirect_fn): self.index = "http://localhost:8000/index" self.username = None self.database = Manager.getDatabaseInstance() self.redirect_url = "http://localhost:9000/intermediate" self.data = { 'consumer_key': '12160-a5732aa14bd49ef07c5a3628', "redirect_uri": self.redirect_url } self.headers = { 'Content-Type': 'application/json; charset=UTF-8', 'X-Accept': 'application/json', } self.redirect_fn = redirect_fn self.crawler = Manager.getCrawlerInstance()
def run_experiment(agents, envs, episode=100, train_after_every=10, save_trajectory_every=100, report_after_every=10): try: for agent in agents: for env in envs: logger.info("Begin {} vs {}".format(str(agent), str(env))) manager = Manager(agent, env) manager.run(episode, train_after_every, save_trajectory_every, report_after_every=report_after_every) manager.report() except: logger.error(traceback.format_exc())
predict_button.pack() export_button = Button(self.root, text="export", command=self.comm_map["export"]) export_button.pack() if debug_mode: prism_data_button = Button(self.root, text="add true data from prism", command=self.comm_map["atdfp"]) prism_data_button.pack() @add_help_menu @add_option_menu @add_file_menu def _get_menu_bar(self): return Menu(self.root, name="menu") def _add_code_window(self): self.code_window = CodeWindow(self.root, self.director) def start_ui_loop(self): self.root.mainloop() if __name__ == '__main__': manager = Manager() director = Director(manager) ui_operator = UIOperator(director, debug_mode=True) director.root = ui_operator.root ui_operator.start_ui_loop()
def init_worker(**kwargs): # To access global Manager global workerManager workerManager = Manager() print " In worker " + str(workerManager)
def main(): name = "" surname = "" param = 0 path = "" query = '' lower = 0 upper = 0 path_2 = "" if len(sys.argv) == 4: query = sys.argv[1] path = sys.argv[2] param = sys.argv[3] elif len(sys.argv) == 7: query = sys.argv[1] path = sys.argv[2] param = sys.argv[3] lower = sys.argv[4] upper = sys.argv[5] path_2 = sys.argv[6] if param == '0': if query is not None: query_list = query.split(" ") if len(query_list) >= 2: name = query_list[0].strip() surname = query[len(name):].strip() else: name = "" surname = query manager = Manager(name, surname) ms.run_individual(manager, surname) wiki1.run(manager, query) generic.get_raw(manager, query) manager.run(path) elif param == '1': if query is not None: query_list = query.split(" ") if len(query_list) >= 2: name = query_list[0].strip() surname = query[len(name):].strip() else: name = "" surname = query manager = Manager(name, surname) ms.run_list_artists(manager, surname) wiki1.get_list(manager, query) manager.run_list(path) elif param == '2': manager = Manager("", "") ms.run_list_kategory(manager, query) wiki1.get_list_kategory(manager, query) manager.run_list(path) elif param == '3': lower_int = int(lower) upper_int = int(upper) manager = Manager("", "") wiki1.get_images_with_index(path, path_2, lower_int, upper_int)
logger.log(Logger.INFO, "Starting Drei") print("Starting Drei") # Initializing database with tables (if necessary) InitTables.main() # Initialize the message queue for crawler and manager manager_queue = multiprocessing.Queue() # Initialize the message queue for manager and webserver manager_webserver_queue = multiprocessing.Queue() # Start the crawler crawler = Crawler(manager_queue, platform.machine() != Const.PI_PLATFORM) crawler.start() # Start the manager manager = Manager(manager_queue, manager_webserver_queue) manager.start() # Start the webserver webserver = Webserver(manager_webserver_queue, manager_queue) webserver.start() # Wait until both processes end manager_queue.close() manager_queue.join_thread() crawler.join() manager.join() webserver.join()
def __init__(self): Manager.__init__(self, PatientAssociationsRepo) self.patient_repo = PatientRepo() self.facility_repo = HealthFacilityRepo() self.user_repo = UserRepo()
def __init__(self): Manager.__init__(self, UserRepo)
def __init__(self): Manager.__init__(self, PatientRepo)
class TestSyncCommands(unittest.TestCase): def setUp(self): self.manager = Manager() filepath = get_prism_model_dir() + get_sep() + "DPM.prism" self.manager.read_model_file(filepath) self.model = self.manager.model ltl = "true U<=10 failure" parsed_ltl = LTLParser().build_parser().parse_line(ltl) self.manager.set_manager_param_simple("duration", 10.0) self.checker = Checker(model=self.model, ltl=parsed_ltl, duration=10.0) self.manager.set_ltl(parsed_ltl) self.prism_x, self.prism_y = parse_csv_cols(get_prism_model_dir() + get_sep() + "Q_TRIGGER_1_20_1.csv") def test_parsing(self): # 测试解析成功 self.assertEqual(self.model.model_type, ModelType.CTMC) logger.info("parsed commands") for module in self.model.modules.values(): for comms in module.commands.values(): if isinstance(comms, list): for comm in comms: logger.info("comm {} from module {}".format( comm.name, module.name)) else: logger.info("comm {} from module {}".format( comm.name, module.name)) def test_gen_path(self): # 测试生成路径的正确性 # 生成的路径要么总长为duration,要么出现failure failure_cnt = 0 for _ in range(5000): self.model.duration = 10 path = self.model.get_random_path_V2() for step in path: logger.info(step) logger.info("----------------") passed_time = path[-1].next_move.passed_time + path[ -1].next_move.holding_time if set(["failure"]) in [step.ap_set for step in path]: failure_cnt += 1 continue if int(passed_time) < 10: failure = True for step in path: logger.error(step) logger.error("-------------") print "failure_cnt={}".format(failure_cnt) def test_checking(self): # 测试模型检测的成功,从而检测模型解析和SMC算法的正确性 logger.info("checker'result is {}".format(self.checker.run_checker())) def test_regression(self): constants = [("q_trigger", [v for v in range(1, 20, 2)])] self.manager.set_train_constants(*constants) self.manager.train_network() self.manager.set_test_xs([test_x for test_x in product(self.prism_x)]) self.manager.run_test(prism_data_path=get_prism_model_dir() + get_sep() + "Q_TRIGGER_1_20_1.csv")
def __init__(self): Manager.__init__(self, ReadingRepo)
def __init__(self): Manager.__init__(self, ReferralRepo)
from manager.Manager import Manager from database.ReferralRepo import ReferralRepo from database.ReadingRepoNew import ReadingRepo from database.PatientRepoNew import PatientRepo from database.HealthFacilityRepoNew import HealthFacilityRepo referralManager = Manager(ReferralRepo) patientManager = Manager(PatientRepo) readingManager = Manager(ReadingRepo) healthFacilityManager = Manager(HealthFacilityRepo)
def __init__(self): Manager.__init__(self, urineTestRepo)