def createNew(self): self.s.cookies.update({ 'advertising_id': Tools().rndDeviceId(), 'appid': 'com.com2us.smon.normal.freefull.apple.kr.ios.universal', 'device': 'iPad5,4', 'did': str(random.randint(200000000, 300000000)) if not self.did else str(self.did), 'native_version': 'Hub v.2.6.4', 'osversion': '10.2', 'platform': 'ios', 'vendor_id': Tools().rndDeviceId() }) self.registered() res = self.key() public_key = res['public_key'] signature = res['signature'] res = self.generate(public_key, signature) self.auth(res['guest_uid']) return res['guest_uid'], res['did']
def set_widget_actions(self): self.crystalFile = self.loadCrystalFileButton.clicked.connect( lambda: Tools().open_file(self)) self.instrumentFile = self.loadInstrumentFileButton.clicked.connect( lambda: Tools().open_file(self)) self.sectorNucButton.clicked.connect(lambda: self.showView('nuc')) self.sectorMagButton.clicked.connect(lambda: self.showView('mag')) pass
def setup_class(self): # 获取token corpid = "" corpsecret = "" url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken" params = {"corpid": corpid, "corpsecret": corpsecret} res = requests.get(url=url, params=params) print("url:%s;params:%s" % (url, params)) print(json.dumps(res.json(), indent=2, ensure_ascii=False)) self.token = res.json()["access_token"] self.t = Tools() # 清理数据 url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_corp_tag_list" params = {"access_token": self.token} res = requests.post(url=url, params=params) print("url:%s;params:%s" % (url, params)) print(json.dumps(res.json(), indent=2, ensure_ascii=False)) rsp = res.json() tag_list = [ tag["id"] for group in rsp["tag_group"] for tag in group["tag"] ] if len(tag_list) > 2: url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_corp_tag" params = {"access_token": self.token} json_datas = {"tag_id": tag_list[2:]} res = requests.post(url=url, params=params, json=json_datas) print("url:%s;params:%s;datas:%s" % (url, params, json_datas)) print(json.dumps(res.json(), indent=2, ensure_ascii=False))
def __init__(self): self.tool = Tools() ''' HanSight_TI_API ''' self.ti_url = 'http://172.16.100.32:80/ti/simplebulkapi'
def cut(self): video_path = self.file_path # 测试文件夹是否存在 save_path = temp_pic_dir + self.temp_save_path tool = Tools() tool.mkdir(save_path) self._video_split(video_path, save_path)
def __init__(self, user, password): self.tools = Tools() self.urlUtil = UrlUtil() self.user = user self.password = password self.session = requests.Session() self.courseUrl = 'https://www.coursera.org/learn/hipython'
def __init__(self): self.svc = None self.X_scaler = None # set default parameters first self.color_space = 'YUV' # Can be YCrCb, RGB, HSV, HLS, YUV, BGR2YCrCb, LUV self.hog_channel = 'ALL' # Numbers of HOG Channels to extract. Value range: [0, 1, 2, ALL] self.orient = 11 # HOG orientations self.pixel_per_cell = 16 # HOG pixels per cell self.cell_per_block = 2 # HOG cells per block self.spatial_size = (16, 16) # Spatial binning dimensions self.hist_bins = 32 # Number of histogram bins self.heat_threshold = 3 # plus half the size the buffer of detections from previous frames self.image_scaling_checked = False self.tools = Tools() self.imageProcessing = ImageProcessingUtilities() self.detectionTracker = DetectionTracker() # Load parameters if corresponding pickle file available classifier_params_count = 2 self.svc, self.X_scaler = self.tools.load_params( classifier_params_count, 'svm_params.pkl') # case no parameters have been stored if self.svc is None: print("Training SVM") self.train_classifier()
def __init__(self): self.tools = Tools() # 右上角 筛选 self.shaixuan = (906, 37) # 热门 self.shoucang = (969, 363) # 姑获鸟 (选择第一个) self.guhuoniao = (812, 208) # 以津真天 (选择第二个) self.yijin = (807, 312) # 山童 (选择第三个) self.shantong = (822, 417) # 挑战 self.tiaozhan = (907, 424) # 40级按钮坐标 self.jibie_40 = (327, 236) # 1级按钮坐标 self.jibie_1 = (102, 241)
def __init__(self, bot_config): self.bot_config = bot_config setup_logging(loglevel="INFO", console_loglevel="DEBUG", log_path_format="logs/botlogs/%Y/%m/%Y-%m-%d.log") self.log = logging.getLogger("bot") conninfo = self.bot_config["Connection Info"] self.networking = Networking(conninfo["host"], conninfo["port"], timeout=conninfo["timeout"], floodcontrol_mode="msg_count", floodcontrol_config={"burst_count_per_10_seconds": 5, "base_delay": 0.5, "max_delay": 2}) msginfo = self.bot_config["Bot Options"]["Message Sending"] self.networking.set_wait_coefficient(base_delay=msginfo["minimum delay"], messages_per_minute=msginfo["messages per minute"], burst=msginfo["burst"]) self.message_handler = MessageHandler() self.user_messages = UserMessages(self) self.server_info = ServerInformation(self) self.channel_manager = ChannelManager(self) self.tools = Tools() self.log.info("All modules configured and set up. Bot is ready to go.") self._shutdown = False
class GetInfoFromZhihu: from tools import Tools tools = Tools() driver = tools.init_web_driver() driver = tools.login(driver=driver) driver = tools.click_more(driver=driver) titlelist = driver.find_elements_by_css_selector( '#zh-profile-activity-page-list > div') # zh-profile-activity-page-list > div:nth-child(1) # zh-profile-activity-page-list > div:nth-child(17) > div # titlelist = driver.find_elements_by_css_selector('#zh-profile-activity-page-list > div:nth-child(1) > div.zm-profile-section-main.zm-profile-section-activity-main.zm-profile-activity-page-item-main') print titlelist resultlist = [] for elem in titlelist: print '++++' + elem.get_attribute('outerHTML').encode( 'utf-8').strip() + "++++++" elemHTML = elem.get_attribute('outerHTML').encode('utf-8').strip() # zh-profile-activity-page-list > div:nth-child(5) actionType = tools.found_action_type(elemHTML=elemHTML) context = tools.get_context(elem) result = [actionType, context] resultlist.append(result) tools.write_to_file(resultlist) # print result + '\n\n\n\n\n\n\n' # source_code = driver.page_source driver.close()
def __init__(self, path): self.tools = Tools() self.image = self.loadImage(path) self.preprocess() sudoku_image = self.cropSudoku() sudoku_image = self.strengthen(sudoku_image) self.cells = Cells(sudoku_image).cells
def __init__(self, name=None): self.name = name self.filename = str(name) + ".json" self.tools = Tools() self.issue = ["", "", "", "", "", ""] if self.name != None: self.issue = self.tools.get_issue(name)
def main(): ts = Tools() partitions = read_in_partitions("partitions/rwpartitions.txt") categories = read_in_categories("categories/bn_matrix_depth_3") names_of_categories = read_in_names("categories/bn_names_depth_3") egos_of_categories = get_ego_relatives_from_list(categories) scores = [] n = len(partitions) count = 0 max_configurations = 10000 word_count = [] for par in partitions: count+=1 if count % 10 == 0: # To let the person running know how far the matching is. print("currently at partition {} of the {}".format(count, n)) unique_terms = get_unique_terms_as_ego(par) dict_with_intensions = get_dict_with_intension(unique_terms, egos_of_categories, names_of_categories) score = find_minimal_complexiy(unique_terms, dict_with_intensions, max_configurations) scores.append(score) word_count.append(len(unique_terms)) # Store data to file. with open("results/complexity_scores.txt", "w") as file: for s in scores: file.write(str(s) + "\n") print("Wrote scores to file complexity_scores.txt in the results directory.") plt.scatter(word_count, scores, c='none', edgecolor="blue") plt.xlabel("wod") plt.ylabel("compl cost") plt.title("Informativeness against Complexity") plt.show()
def hiveLogin(self, user, password): self.s.cookies.update({ 'advertising_id': Tools().rndDeviceId(), 'appid': 'com.com2us.smon.normal.freefull.apple.kr.ios.universal', 'device': 'iPad5,4', 'did': str(random.randint(200000000, 300000000)) if not self.did else str(self.did), 'native_version': 'Hub v.2.6.4', 'osversion': '10.2', 'platform': 'ios', 'vendor_id': Tools().rndDeviceId() }) self.registered() self.s.post( 'https://hub.qpyou.cn/auth', data= '{"language":"en","timezone":null,"game_language":"en","server_id":"","device_country":"RU","hive_country":"DE"}', allow_redirects=False) data = {'id': user, 'password': '', 'dkagh': self.MD5(password)} self.s.get('https://hub.qpyou.cn/auth/recent_account') rr = self.s.post( 'https://hub.qpyou.cn/auth/login_proc', data=data, headers={ 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1', 'Referer': 'http://hub.qpyou.cn/auth/login' }, allow_redirects=False) sss = rr.headers['Location'].split('&') sessionkey = sss[3].replace('sessionkey=', '') _did = sss[2].replace('did=', '') res = self.me() if not res: return None return res['uid'], _did, sessionkey
def get_coin_price_api(self, symbol): coin_id = COIN_SYMBOL_ID.get(symbol.upper(symbol.strip(symbol))) _url = self.homeUrl + symbol if coin_id: _url = self.homeUrl + coin_id objs = Tools().request(_url) """ [{ "id": "bitcoin", "name": "Bitcoin", "symbol": "BTC", "rank": "1", "price_usd": "10667.8", "price_btc": "1.0", "24h_volume_usd": "8203140000.0", "market_cap_usd": "180068463575", "available_supply": "16879625.0", "total_supply": "16879625.0", "max_supply": "21000000.0", "percent_change_1h": "-1.04", "percent_change_24h": "-5.07", "percent_change_7d": "9.23", "last_updated": "1519289669" }] """ _map = " exchange:CoinMarketCap" if (objs is not None) and len(objs) > 0: jsonobj = objs[0] if 'symbol' in jsonobj: _tmp = " symbol:%s" % jsonobj['symbol'] _map = _map + _tmp if 'price_usd' in jsonobj: _tmp = "\n price_usd:%s" % jsonobj['price_usd'] _map = _map + _tmp if 'price_btc' in jsonobj: _tmp = "\n price_btc:%s" % jsonobj['price_btc'] _map = _map + _tmp if 'percent_change_1h' in jsonobj: _tmp = "\n change_1h:%.2f%%" % float( jsonobj['percent_change_1h']) _map = _map + _tmp if 'percent_change_24h' in jsonobj: _tmp = "\n change_24h:%.2f%%" % float( jsonobj['percent_change_24h']) _map = _map + _tmp if 'percent_change_7d' in jsonobj: _tmp = "\n change_7d:%.2f%%" % float( jsonobj['percent_change_7d']) _map = _map + _tmp if 'last_updated' in jsonobj: _tmp = "\n time:%s" % (time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(long(jsonobj['last_updated'])))) _map = _map + _tmp return _map else: return "cannot query the price of %s (query by coin-id,not symbol) from CoinMarketCap" % symbol
def __init__(self, taxonomy, protein): self.Taxonomy = taxonomy self.Protein = protein self.ncbi_api = Retrieve() self.tools = Tools() self.dataset = None self.fasta = None self.summary = None
def __init__(self): """ Widget containing the entire Zebra Mode view. """ super().__init__() # ---------------------------------------------------------------------- # PREPARE # ---------------------------------------------------------------------- grid = QGridLayout() self.setLayout(grid) # Tools.View() groups Widgets for ease of use. self.two = View() # Define Files so IDE does not issue warnings. self.dataFile = None # ---------------------------------------------------------------------- # DEFINE WIDGETS # ---------------------------------------------------------------------- # Add empty label as spacer after buttons.I suspect this has a side effect. # When adding Buttons20, we mean for them to span from grid position (3,1) to (3,2). # However to mainreate the mainorrect visual effect they must also mainover the invisible spacer mainolumn. # Thus we set them to span from grid position (3,1) to (3,3). grid.addWidget(QLabel(), 10, 10) self.two.loadDataButton = QPushButton("Load Data File") self.two.loadDataButton.setMaximumWidth(200) grid.addWidget(self.two.loadDataButton, 1, 0) self.two.text = Text("List of Files:\n+ File 1\n+ File 2") grid.addWidget(self.two.text, 0, 0) self.two.table = Table() grid.addWidget(self.two.table, 0, 1) self.two.visualize = Visualize() grid.addWidget(self.two.visualize, 0, 2) self.two.buttons11 = Buttons11(self) grid.addWidget(self.two.buttons11, 1, 1) self.two.buttons12 = Buttons12(self) grid.addWidget(self.two.buttons12, 1, 2) # ---------------------------------------------------------------------- # SET WIDGET ACTIONS # ---------------------------------------------------------------------- self.dataFile = self.two.loadDataButton.clicked.connect( lambda: Tools().open_file(self)) # ---------------------------------------------------------------------- # FINISH # ---------------------------------------------------------------------- pass
def __init__(self, file_name): self.file_path = video_path + file_name # 内部的file name是不带后缀的 f_suffix = file_name.split('.')[-1] self.file_name = file_name.replace('.'+f_suffix, '') self.sound_file_path = sound_dir # 创建那个目录 tools = Tools() tools.mkdir(self.sound_file_path)
def __init__(self): """Constructor. Defines instance variables """ self.conn = sqlite3.connect(DATABASE_FILE) self.conn.text_factory = str self.conn.row_factory = sqlite3.Row self.cursor = self.conn.cursor() self.create_table() self.tools = Tools()
def configread(self): # get user to input case number file = input("Please enter case name/number here: ") # use * to get list of case_logs path dir = os.listdir(os.path.dirname(os.path.abspath("case_logs/*"))) # check if the json file is case_logs dir for i in dir: # or condition in case user enters case name with .json if file == i[:-5] or file == i: print("File Found!") path = str(os.path.dirname( os.path.abspath("case_logs/*"))) + "/" + str(i) with open(path, 'r') as f: config = json.load(f) self.case_name = config["CaseID"] self.secure_store_location = config["SSPath"] self.evidence = config["EvidenceFile"] self.mount_point = config["MountPoint"] f.close() print("Case parameters retrieved from log file!") print( "So long as the location of your securestore and evidence haven't changed you can continue with examination and analysis" ) Tools().hash(self.case_name, self.evidence, self.secure_store_location) # options for if file not found else: while True: print( "There doesn't seem to be a case log file that matches your input" ) print( "Please try again! Alternatively Press \033[94mENTER\033[0m to view a list of case names" ) user_input = input( "\033[31mOR\u001b[0m type \033[92mback\033[0m and press \033[94mENTER\033[0m to go back to start: " ) if user_input == "": case_list = os.listdir( os.path.dirname(os.path.abspath("case_logs/*"))) print(case_list) continue elif user_input == "back" or "back".upper( ) or "b" or "Back": pass else: pass break self.configread()
def __init__(self): self.username = None self.password = None self.login_succ = False self.mins = 25 self.secs = 0 self.tools = Tools() self.user = User() self.now_issue = None self.now_time = None
def __init__(self): wx.Frame.__init__(self,None,wx.ID_ANY,kdj_name_version) self.options=Options(wx.StandardPaths.Get().GetUserConfigDir()) try: self.tools=Tools(wx.BeginBusyCursor,wx.EndBusyCursor) except Exception,e: wx.MessageBox('Failed to find necessary tools:\n'+str(e),'Error',style=wx.OK|wx.CENTRE|wx.ICON_ERROR) sys.exit(1)
def __init__(self): self.s=requests.session() self.s.verify=False self.s.headers.update({'Content-Type':'application/x-www-form-urlencoded','User-Agent':'DotFFWWMOPS/531 CFNetwork/811.4.18 Darwin/16.5.0'}) if 'win' in sys.platform: self.s.proxies.update({'http': 'http://127.0.0.1:8888','https': 'https://127.0.0.1:8888',}) self.base='https://ffrk.denagames.com' self.appspot=Appspot() self.tools=Tools() self.crypter=Crypter() self.begin_token=None self.battle_session_key=None
def send_packs(self, ids, chat_id, reply_to_message_id=None, is_desc=True, pix=None): pix = self.get_pix(chat_id) if not pix else pix for pack in Tools().min_split(ids, self.PACK_OF_SIMILAR_POSTS): all_info = pix.info_packs(pack) all_media = [] for one in all_info: pic = self.prepare_picture(one) all_media.append(imphoto(pic['url'], caption=pic['caption'] if is_desc else '', parse_mode='HTML')) result = self.b.media(all_media, chat_id=chat_id, reply_to_message_id=reply_to_message_id if reply_to_message_id else '').send() if not result['ok']: self.send_pack_by_one(pack, chat_id, reply_to_message_id=reply_to_message_id, is_desc=is_desc, pix=pix)
def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return try: tools = Tools() version = tools.get_app_info("__version__") name = tools.get_app_info("__title__") python_version = "{n} {v}".format(n="Python", v=sys.version) click.echo("{n} {v}\n{p}".format(n=name, v=version, p=python_version)) except KeyError: pass ctx.exit()
def __init__(self): pygame.init() self.tools = Tools() self.port_eye_cam = 9999 self.port_front_cam = 10000 self.buff_size = 65535 # 设置Socket参数 [接收端IP,端口,缓冲容量] self.host = self.tools.get_host_ip() # 瞳孔检测坐标 # pupil_det_x = 0 # pupil_det_y = 0 # 映射坐标圆半径 self.radius = 20
def get_coin_price_api(self, symbol): # http://api.zb.com/data/v1/ticker?market=btc_usdt _symbol = symbol.strip().upper() coin_market = ZB_COIN_MARKET_USDT.get(_symbol) _data = {'market': _symbol} if coin_market: _data = {'market': coin_market} objs = Tools().request(self.homeUrl, _data) """ { "ticker": { "vol": "2681.2393", "last": "9925.0", "sell": "9924.7", "buy": "9921.45", "high": "10979.99", "low": "9866.03" }, "date": "1519355461791" } """ _map = " exchange:zb\n symbol:%s" % coin_market if objs and ('ticker' in objs): jsonobj = objs['ticker'] if 'last' in jsonobj: _tmp = "\n price:%s" % jsonobj['last'] _map = _map + _tmp if 'buy' in jsonobj: _tmp = "\n buy:%s" % jsonobj['buy'] _map = _map + _tmp if 'sell' in jsonobj: _tmp = "\n sell:%s" % jsonobj['sell'] _map = _map + _tmp if 'high' in jsonobj: _tmp = "\n high_24h:%s" % jsonobj['high'] _map = _map + _tmp if 'low' in jsonobj: _tmp = "\n low_24h:%s" % jsonobj['low'] _map = _map + _tmp if 'vol' in jsonobj: _tmp = "\n vol_24h:%s" % jsonobj['vol'] _map = _map + _tmp if 'date' in objs: _time = objs['date'] _map = _map + "\n time:%s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(long(_time)/1000))) return _map else: return "cannot query the price of %s from zb" % _symbol
def __init__(self): self.__tools = Tools() self.__AppID = self.__get_AppID() # 百度AppID self.__APIKey = self.__get_APIKey() # 百度APIKey self.__SecretKey = self.__get_SecretKey() # 百度SecretKey self.__format = self.__get_format( ) # 语音文件的格式,pcm 或者 wav 或者 amr。不区分大小写。推荐pcm文件 self.__rate = self.__get_rate() # 采样率,16000,固定值 self.__cuid = self.__get_cuid( ) # 用户唯一标识,用来区分用户,填写机器 MAC 地址或 IMEI 码,长度为60以内 self.__dev_pid = self.__get_dev_pid( ) # 不填写lan参数生效,都不填写,默认1537(普通话 输入法模型) self.__client = AipSpeech(self.__AppID, self.__APIKey, self.__SecretKey)
def __init__(self): self.tools = Tools() # 图片分辨率: 宽480 x 长640 self.res = [480, 640] # 人工调节瞳孔可能出现范围 [x,y,w,h] self.roi_x = 100 self.roi_y = 120 self.roi_w = 350 self.roi_h = 240 # 比较的最长线段最小阈值 self.max_len_thresh = 10 # 灰度图转二值图阈值 self.bin_thresh = 30 # 十字光标大小 self.cross_size = 40
def setUp(self): """Set up filenames for running the test. A fake U-Boot binary is created ready for use in tests. """ self._file_upto = 0 # How many files we have created self.tmpdir = tempfile.mkdtemp() self.output = cros_output.Output() self.tools = Tools(self.output) self.tools.PrepareOutputDir(None) self.bundle = Bundle(self.tools, self.output) self.uboot_fname = self.MakeRandomFile(500 * 1024) self.bmpblk_fname = os.path.abspath('bin/bmpblk.bin') self.bct_fname = os.path.abspath('bin/board.bct') self.bundle.SetDirs('##/usr/share/vboot/devkeys') self.bundle.SetOptions(False, None)