def crawler(who, what, fmt): if not os.path.isdir(settings.tmp_folder): os.mkdir(settings.tmp_folder) path = who + os.sep + what print path if not os.path.isdir(path): os.makedirs(path) exists = subject.exist(path) subjects = collect.feed_from_collect(what, who) ids = [] dates = {} for s in subjects: url = s['url'][:-1] id = url[url.rfind('/') + 1:] ids.append(id) dates[id] = s['date'] for id in ids: if not id in exists: util.sleep(settings.interval) #src = subject.pull(fmt, settings.tmp_folder, what, id) src = subject.pull_by_html(what, settings.tmp_folder, id) subject.archive(src, os.path.join(who, what)) print '[%s] -> [%s]' % (src, os.path.join(who, what)) subject.append_date(path, dates)
def testTakePicture(self): """ Summary:testCapturePictureAndDelete: Take a picture, then view and delete the picture. Steps:1. Open Camera app 2. Capture a picture 3. Touch thumbnail to view the picture 4. Touch Delete button to delete the picture 5. Exit Camera app """ #Start camera and check if sucessful d.start_activity(component='com.intel.camera22/.Camera') assert d(description='Shutter button').wait.exists(timeout=5000), 'can not launch camera in 5s' #Take picture d(description='Shutter button').click.wait() u.sleep(5) d(description='Most recent photo').click.wait() d.click(500,500) assert d(description="Delete").wait.exists(timeout=3000), 'No picture to delete.' d(description='Delete').click.wait() d(text='Delete').click.wait() u.sleep(3) assert d(description="Shutter button").wait.exists(timeout=5000), 'unable back to camera after delete in 5s.'
def developer_read_store_loop(developer_href, start_num): start_num = int(start_num) flag = True while flag == True: flag = developer_read_store(developer_href, start_num) start_num = start_num + 12 util.sleep()
def msigReplaceSystem(): run(args.cleos + 'push action eosio buyrambytes' + jsonArg(['eosio', accounts[0]['name'], 200000]) + '-p eosio') sleep(1) msigProposeReplaceSystem(accounts[0]['name'], 'fast.unstake') sleep(1) msigApproveReplaceSystem(accounts[0]['name'], 'fast.unstake') msigExecReplaceSystem(accounts[0]['name'], 'fast.unstake')
def testBaidumaps(self): #Check and set wifi u.openWifi(d, True) #Launch Baidu map app d.start_activity(component='com.baidu.BaiduMap/com.baidu.baidumaps.WelcomeScreen') if d(text='不要福利').wait.exists(timeout=5000): d(text='不要福利').click.wait() if d(text='以后再说').wait.exists(timeout=5000): d(text='以后再说').click.wait() if d(text='以后再说').wait.exists(timeout=2000): d(text='以后再说').click.wait() #Check if baidu map can be launched successfully assert d(text='附近').wait.exists(timeout=5000), 'Not enter main map activity' assert d(text='路线').wait.exists(timeout=2000), 'Not enter main map activity' #Swipe on the map d.swipe(340, 340, 340, 900, steps=5) #Locate to current location u.sleep(2) d.expect('location.png') d.click('location.png') #Located successful assert d(text='我的位置').wait.exists(timeout=3000), 'can not locate'
def testMO_MTSms(self): #Set receiver and msg content str_receiver = '10086' str_content = 'Message Test Content' #Start Messaging and check if sucessful d.start_activity(component='com.android.mms/.ui.MmsTabActivity') assert d(text='Messages').wait.exists(timeout=3000), 'can not launch message in 3s' #Delete messages if there is any message. if not d(textStartsWith="No conversations").wait.exists(timeout=2000): d(className='android.view.View').long_click() if d(text='Select all').wait.exists(timeout=3000): d(text='Select all').click.wait() d(text='Delete').click.wait() d(text='Delete').click.wait() assert d(textStartsWith="No conversations").wait.exists(timeout=10000), 'Delete messages failed' #Compose message d(text='New message').click.wait() d(className='android.widget.EditText', index=0).set_text(str_receiver) assert d(text=str_receiver).wait.exists(timeout=10000), 'receiver number input error' d(className='android.widget.EditText', index=1).set_text(str_content) assert d(text=str_content).wait.exists(timeout=10000), 'content input error' d(description='Send message').click.wait() #assert d(text='Sending').wait.exists(timeout=3000), 'Not begin to sending in 3s' u.sleep(3) assert d(text='Sending').wait.gone(timeout=20000), 'sms sending failed in 20s'
def startWallet(): sleep(.4) output = getOutput(args.cleos + 'wallet create') match = re.search(r'"([a-zA-Z0-9]+)"', output) pw = match.group(1) with open('/work/wallet-info-default.json', 'w') as f: f.write(json.dumps({ 'password': pw }))
def openBrowser(self, wifi): u.openWifi(d, wifi) #Launch browser and check if launch sucessful d.start_activity(component='com.android.browser/.BrowserActivity') assert d(className='android.widget.ImageButton', index=3).wait.exists(timeout=5000), 'Launch browser failed in 5s' #Open a new page #and go to www.qq.com d(className='android.widget.ImageButton', index=3).click.wait() assert d(text="Bookmarks").wait.exists(timeout=3000), 'Open new page failed in 3s' d(className='android.widget.EditText').set_text('wap.qq.com') d.press('enter') #Sleep 15s to wait loading web page u.sleep(15) flag = True i = 0 while(flag and i < 9): i = i + 1 d.swipe(400, 1000, 400, 500, steps=6) u.sleep(5) if not d.find('browser_blank.png'): flag = False if flag: assert False, 'Open the web page failed in 60s.' else: assert True
def weibo(self, wifi): u.openWifi(d, wifi) #Open sina weibo and check if successful d.start_activity(component='com.sina.weibo/.SplashActivity') assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'weibo cient unable to open in 10 secs' #Clear the 'sent fail' prompt if d.exists(text='Sent failed. It has been saved in the draft.'): d(text='Sent failed. It has been saved in the draft.').click.wait() d.press('back') #Swipe to fetch new messages 3 times for i in range(3): #d.swipe(340, 340, 340, 1000, steps=5) d(description='首页列表').click.wait() d(className='android.widget.LinearLayout', index=0).click.wait() u.sleep(5) #Compose new message #Switch to message editor d(className='android.widget.TextView', description="MainEdit").click.wait() assert d(className='android.widget.TextView', text="New Weibo").wait.exists(timeout=3000), 'unable to compose message' #Fetch and input random TEXT, and send the message d(className='android.widget.EditText').set_text(u.fetchText()) d(text='Send', description='Send').click.wait() assert not d(text='Sent failed. It has been saved in the draft.').wait.exists(timeout=10000), 'msg send failed' assert d(className='android.widget.TextView', description="MainEdit").wait.exists(timeout=10000), 'unable to back to home screen in 10 secs'
def proxyVotes(b, e): vote(firstProducer, firstProducer + 1) proxy = accounts[firstProducer]['name'] retry(args.cleos + 'system regproxy ' + proxy) sleep(1.0) for i in range(b, e): voter = accounts[i]['name'] retry(args.cleos + 'system voteproducer proxy ' + voter + ' ' + proxy)
def testLaunch(self): #Launch game d.start_activity(component='com.rovio.angrybirdsstarwars.ads.iap/com.rovio.fusion.App') u.sleep(40) d.expect('loaded.png', timeout=20, msg='Fail to load app') d.press('back') d.expect('ok.png', timeout=10, msg='Fail to find ok button') d.click(788,385)
def testLaunch(self): #Launch game d.start_activity(component='com.rovio.angrybirdsstarwars.ads.iap/com.rovio.fusion.App') u.sleep(30) d.expect('loaded.png', timeout=30, msg='failed to load') d.press('back') d.expect('ok.png', timeout=30, msg='failed to find ok button') d.click(1060,590)
def CreateTokens(): #datx util.run( 'cldatx ' + 'push action datxos.token create \'["datxos", "10000000000.0000 %s"]\' -p datxos.token' % (symbol) + ' -x 3500') #totalAllocation = allocateFunds(0, len(accounts)) util.run( 'cldatx ' + 'push action datxos.token issue \'["datxos", "%s", "memo"]\' -p datxos' % intToCurrency(totalAllocation)) #btc util.run( 'cldatx ' + 'push action datxos.dtoke create \'["datxos.dbtc", "21000000.0000 DBTC",0,0,0]\' -p datxos.dtoke' ) util.run( 'cldatx ' + 'push action datxos.dtoke issue \'["datxos.dbtc", "21000000.0000 DBTC", "memo"]\' -p datxos.dbtc' ) #util.run('cldatx '+ 'push action datxos.dtoke transfer \'{"from":"datxos.dtoke","to":"alice","quantity":"100.0000 DBTC","memo":"test"}\' -p datxos.dtoke') #eth util.run( 'cldatx ' + 'push action datxos.dtoke create \'["datxos.deth", "102000000.0000 DETH",0,0,0]\' -p datxos.dtoke' ) util.run( 'cldatx ' + 'push action datxos.dtoke issue \'["datxos.deth", "102000000.0000 DETH", "memo"]\' -p datxos.deth' ) #eos util.run( 'cldatx ' + 'push action datxos.dtoke create \'["datxos.deos", "1000000000.0000 DEOS",0,0,0]\' -p datxos.dtoke' ) util.run( 'cldatx ' + 'push action datxos.dtoke issue \'["datxos.deos", "1000000000.0000 DEOS", "memo"]\' -p datxos.deos' ) util.run( 'cldatx ' + 'set account permission datxos.dbtc active \'{"threshold": 1,"keys": [{"key": "DATX8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr","weight": 1}],"accounts": [{"permission":{"actor":"datxos.charg","permission":"datxos.code"},"weight":1},{"permission":{"actor":"datxos.extra","permission":"datxos.code"},"weight":1}]}\' owner -p datxos.dbtc' ) util.run( 'cldatx ' + 'set account permission datxos.deth active \'{"threshold": 1,"keys": [{"key": "DATX8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr","weight": 1}],"accounts": [{"permission":{"actor":"datxos.charg","permission":"datxos.code"},"weight":1},{"permission":{"actor":"datxos.extra","permission":"datxos.code"},"weight":1}]}\' owner -p datxos.deth' ) util.run( 'cldatx ' + 'set account permission datxos.deos active \'{"threshold": 1,"keys": [{"key": "DATX8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr","weight": 1}],"accounts": [{"permission":{"actor":"datxos.charg","permission":"datxos.code"},"weight":1},{"permission":{"actor":"datxos.extra","permission":"datxos.code"},"weight":1}]}\' owner -p datxos.deos' ) util.sleep(1)
def parse(driver, url): products = [] driver.get(url) driver.execute_script('window.scrollBy(0,50000)') util.sleep(3) elements = util.find_elements_by_css_selector(driver, 'a.js-producttile_link') for element in elements: products.append(element.get_attribute('href').strip()) return ';'.join(products)
def parse(driver, url): products = [] driver.get(url) for i in range(10): # 确保页面拉到最下面,所有商品得到展示。 driver.execute_script('window.scrollBy(0, 10000)') util.sleep(1) elements = util.find_elements_by_css_selector(driver, 'li.item > div> div.product-image-box >a') for element in elements: products.append(element.get_attribute('href').strip()) return ';'.join(products)
def workout_step(self, was_office_hours): """ Runs a step of the workout bot, handling exceptions. Returns True iff is_office_hours returns true before the current workout. """ is_office_hours = self.bot.is_office_hours() try: self._workout_step(was_office_hours, is_office_hours) except NoEligibleUsersException: util.sleep(minutes=5) return is_office_hours
def parse(driver, url): products = [] driver.get(url) elements = util.find_elements_by_css_selector(driver, 'a.shelf_view-all') for element in elements: if element.is_displayed(): driver.execute_script('arguments[0].click();', element) util.sleep(3) elements = util.find_elements_by_css_selector(driver, 'li.product > div > a') for element in elements: products.append(element.get_attribute('href').strip()) return ';'.join(products)
def google_plus_read_main(): finish = True rows = db_app.db_get_g(db_sql.sql_app_google_plus_get, ()) for row in rows: finish = False app_id = row[0] google_plus_href = row[1] try: google_plus_read(app_id, google_plus_href, ) util.sleep() except Exception as e: err.except_p(e)
def main(): parser = argparse.ArgumentParser(description='timer') parser.add_argument('NUM', type=int, default=1, help='time to wait') parser.add_argument('--period', choices=['min','sec'], default='min', help='period for input') args = parser.parse_args() seconds = args.NUM if args.period == 'min': seconds = seconds * 60 util.sleep(seconds)
def attack(self): util.screen_shot(self.hwnd, self.name) x, y = util.get_location('temp\\' + self.name + '\\screenshot.png', 'zhandouclick.png') if x > 1000 and y > 400: util.sleep(1000) util.click_pos(self.hwnd, x, y) self.sell() util.sleep(1000) util.click_pos(self.hwnd, 1194, 172) else: util.click_pos(self.hwnd, 516, 456)
def app_read_main_temp(): finish = True rows = db_app.db_get_g(db_sql.sql_app_read_get, ()) i_t = len(rows) i = 0 for row in rows: i = i + 1 print '%d of %d'%(i, i_t), finish = False app_id = row[0] app_read(app_id) util.sleep() return finish
def parse(driver, url): products = [] driver.get(url) driver.execute_script('window.scrollBy(0,50000)') util.sleep(3) elements = util.find_elements_by_css_selector( driver, 'section.products > article.item > div > a') if not elements: # https://www.chloe.cn/cn/chloe/%E5%A5%B3%E5%A3%AB/subhome/accessories_section elements = util.find_elements_by_css_selector(driver, 'article.product >a') for element in elements: products.append(element.get_attribute('href').strip()) return ';'.join(products)
def resign(account, controller): list_con=['datxos.dbtc','datxos.deos','datxos.deth'] if account in list_con: updateAuth_spe(account, 'owner', '', controller) updateAuth_spe(account, 'active', 'owner', controller) elif account == "datxos.extra": updateAuth_extra(account, 'owner', '', controller) updateAuth_extra(account, 'active', 'owner', controller) else: updateAuth(account, 'owner', '', controller) updateAuth(account, 'active', 'owner', controller) util.sleep(1) util.run('cldatx ' + 'get account ' + account)
def arena_wait(): util.log("Wait for arena finish..") for i in range(0, 300): util.sleep(1) message = telega.last_msg() if 'Рейтинги обновлены:' in message.message: return if 'Даже драконы не могут' in message.message: return if 'Тебе бы подлечиться.' in message.message: return if 'У тебя нет денег, чтобы оплатить вход.' in message.message: return util.log("Arena waiting timeout!")
def begin(self): util.click_pos(self.hwnd, self.pos_x, self.pos_y) util.sleep(1000) util.screen_shot(self.hwnd, self.name) x, y = util.get_location('temp\\' + self.name + '\\screenshot.png', 'selectterm.png') while x < 1000: util.click_pos(self.hwnd, self.pos_x, self.pos_y) util.sleep(1000) util.screen_shot(self.hwnd, self.name) x, y = util.get_location('temp\\' + self.name + '\\screenshot.png', 'selectterm.png') util.click_pos(self.hwnd, 1002, 573)
def testVideoPlayer(self): #Start video player and check if successful d.start_activity(component='com.miui.video/.HomeActivity') assert d(text='Local').wait.exists(timeout=5000) , 'video app can not be launched.' #Go to local video and start to play video d(text='Local').click.wait() assert d(text='bbb.mp4').wait.exists(timeout=3000) , 'Switch to local video.' d(text='bbb.mp4').click.wait() assert d(text='bbb.mp4').wait.gone(timeout=3000), 'Not switch to playing' #Wait to finish playing and check if back to video list u.sleep(600) assert d(text='bbb.mp4').wait.exists(timeout=10000)
def category_read_main(): finish = True rows = db_play.db_get_g(db_sql.sql_cate_read_get, ()) for row in rows: finish = False cate_name = row[0] cate_path = row[1] cate_param = row[2] cate_type = row[3] try: category_read(cate_path, cate_name, cate_type, cate_param) db_play.db_execute_g(db_sql.sql_cate_read_update, (cate_name, cate_path, cate_param, cate_type, )) except Exception as e: err.except_p(e) util.sleep() return finish
def on_actions(self, actions): #self.maybe_go_insane() if not self.sane: return log.info(self.log('actions: %s' % actions)) action = find_first_common_element(self.actions_to_do, actions) if action == 'dial': if self.dial_counter >= 1: return self.dial_counter += 1 if action == 'transfer': if self.transfer_counter >= 1 or len(CallHandler.lines_calls) < 2: return self.transfer_counter += 1 if self.dial_counter > 50: print 'OVERFLOW=========================================' import sys; sys.exit(1) if action is not None: log.info(self.log('generated call action: %s' % action)) if action == 'number': self.call_action('onhook', []) self.call_action('offhook', []) self.call_action(action, generate_params(action, self.params_generators)) if action == 'number': yield sleep()
def parse(driver, url): products = [] driver.get(url) while True: elements = util.find_elements_by_css_selector(driver, 'a.bul-btn-more') cont = False for element in elements: if element.is_displayed(): cont = True driver.execute_script('arguments[0].click();', element) util.sleep(3) if not cont: break elements = util.find_elements_by_css_selector(driver, 'a.product-link') for element in elements: products.append(element.get_attribute('href').strip()) return ';'.join(products)
def fetch(self, url, data=None, retries=4, nap=1): err = False text = None cache_url = url if data: cache_url += "?" + urlencode(data) if self.read_cache and nap < 2: text = self.cache.get(cache_url) if not text: try: if data: text = self.s.post(url, data).text else: text = self.s.get(url).text if self.write_cache: self.cache.put(cache_url, text) except Exception as e: err = True log.exception("Failed to get {}".format(url)) ret = text if not err: if self.text_handler: try: ret = self.text_handler(text) if not ret: log.debug("Text produced false value: {} [...]".format( str(text)[:1000])) err = True except Exception as e: err = True log.exception("Failed to handle text: {} [...]".format( str(text)[:1000])) if err: if retries <= 0: log.debug('No retries left; returning None') return None if nap > 1: sleep(nap) return self.fetch(url, data, retries=retries - 1, nap=nap * 4) return ret
def testVideoPlayer(self): #Launch video and check if successful d.start_activity(component='com.miui.video/.HomeActivity') assert d(text='电视直播').wait.exists(timeout=5000) , 'video app can not be launched.' #Switch to local video and find bbb.mp4 to play if d(text='我的视频').wait.exists(timeout=1000): d(text='我的视频').click.wait() if d(text='Local').wait.exists(timeout=1000): d(text='Local').click.wait() assert d(text='bbb.mp4').wait.exists(timeout=3000) , 'Switch to local video.' d(text='bbb.mp4').click.wait() assert d(text='bbb.mp4').wait.gone(timeout=3000), 'Not switch to playing' #After finish playing, should back to video list u.sleep(600) assert d(text='bbb.mp4').wait.exists(timeout=10000) d.press('back')
def create_and_start(self): util.debug("Starting and restoring wallet {}".format(self)) util.rm_file_if_exists(self.fname) util.ensure_dir( "~/.electrum" ) # TODO not sure why I have to do this, but it crashes otherwise # start daemon # TODO messy; assumes it takes 5 seconds; for some reason shell_blocking won't work util.shell_expect("electrum daemon start") util.sleep(5) util.shell_expect(self._args("electrum daemon start")) util.sleep(5) util.shell_blocking( self._with_password( self._args("electrum restore -o \"{}\"".format(self.seed)))) util.shell_blocking(self._args("electrum daemon load_wallet")) util.debug("Started and restored wallet {}".format(self))
def related_read(app_id): try: url = '/%s/details?id=%s'%(android_root, app_id) print '** related %s **'%(url) status, body = android_https_get(url) #print status, body if status == 404: print '== 404' db_related.db_execute_g(db_sql.sql_related_read_update, (1, str(datetime.now()), app_id)) return if status != 200: raise Exception('related read https connection error: %s'%(str(status))) soup = BeautifulSoup(body) related_view(app_id, soup) related_install(app_id, soup) db_related.db_execute_g(db_sql.sql_related_read_update, (1, str(datetime.now()), app_id)) util.sleep() except Exception as e: err.except_p(e)
def testMoMMS(self): #Set receiver and msg content str_receiver = '13501278511' str_content = 'Message Test Content' #Start Messaging and check if sucessful d.start_activity(component='com.android.mms/.ui.MmsTabActivity') assert d(text='New message', className='android.widget.Button').wait.exists(timeout=5000), 'can not launch message in 3s' #Delete messages if there is any message. if not d(text="No conversations.").wait.exists(timeout=1000): d(className='android.view.View').long_click() if d(text="Select all").wait.exists(timeout=3000): d(text="Select all").click.wait() d(text="Delete").click.wait() d(text="Delete").click.wait() #Compose message d(text='New message').click.wait() d(className='android.widget.EditText', index=0).set_text(str_receiver) assert d(text=str_receiver).wait.exists(timeout=10000), 'receiver number input error' d(className='android.widget.EditText', index=1).set_text(str_content) assert d(text=str_content).wait.exists(timeout=10000), 'content input error' #Add attachment from camera d(descriptionContains='dd attachment').click.wait() assert d(text='Capture picture').wait.exists(timeout=3000), 'no adding attachment panel' d(text='Capture picture').click.wait() assert d(description='Shutter button').wait.exists(timeout=3000), 'no camera' d(description='Shutter button').click.wait() assert d(className='android.widget.ImageView', index=1, description='Shutter button').wait.gone(timeout=10000), 'Take picture failed' assert d(className='android.widget.ImageView', index=1).wait.exists(timeout=5000), 'No confirm for picture' d(className='android.widget.ImageView', index=1).click.wait() assert d(text='MMS').wait.exists(timeout=5000), 'add attachment failed' #Send MMS d(descriptionContains='end message').click.wait() assert d(text='Sending').wait.exists(timeout=10000), 'No sending status in 10s' u.sleep(20) assert d(text='Sending').wait.gone(timeout=70000), 'MMS sending failed in 90s'
def testTakePicture(self): #Start camera and check if sucessful d.start_activity(component='com.android.camera/.Camera') assert d(description='Shutter button').wait.exists(timeout=5000), 'can not launch camera in 5s' #Take picture d(description='Shutter button').click.wait() u.sleep(5) d(description='Shutter button').click.wait() u.sleep(5) #Delete the recent picture d(description='Most recent photo').click.wait() assert d(text="Delete").wait.exists(timeout=3000), 'No picture to delete.' #d(text="Delete").click.wait() #d(text="OK").click.wait() #If there is not only one picture #if d(text="Delete").wait.exists(timeout=2000): d.press('back') assert d(description="Shutter button").wait.exists(timeout=5000), 'unable back to camera after delete in 5s.'
def video_read_main(): finish = True rows = db_app.db_get_g(db_sql.sql_video_get, ()) i_t = len(rows) i = 0 for row in rows: i = i + 1 print '%d of %d'%(i, i_t), finish = False app_id = row[0] video_href = row[1] view_total = row[2] video_href_d = video_href.split('/')[-1] video_id = video_href_d.split('?')[0].strip() try: video_read(video_id, app_id, video_href) util.sleep() except Exception as e: err.except_p(e) return finish
def testGallery(self): #Launch gallery and check if successful d.start_activity(component='com.miui.gallery/.app.Gallery') assert d(textStartsWith='Cloud', className='android.widget.TextView').wait.exists(timeout=5000), 'Launch gallery failed in 5s' d(textStartsWith='Cloud', className='android.widget.TextView').click.wait() assert d(text='New', className='android.widget.TextView').wait.exists(timeout=5000), 'Switch to cloud images failed in 5s' #Select and open the cloud gallery d.click(510,331) u.sleep(2) d.click(111,222) u.sleep(3) for m in range(3): for i in range(5): d().swipe.left() for i in range(5): d().swipe.right() d.press('back') u.sleep(1) d.press('back') u.sleep(1)
def createStakedAccounts(begin, end): #(b,e) =(0,len(accounts))=(0,7),(0~3)users,(4~7)producers for i in range(begin, end): a = accounts[i] stakeNet = 500000000000 #50000000DATX stakeCpu = 500000000000 #50000000DATX stakeRam = 500000000000 #50000000DATX small_stake = 5000000 #500DATX util.retry( 'cldatx ' + 'system newaccount --transfer datxos %s %s --stake-net "%s" --stake-cpu "%s" --buy-ram "%s" ' % (a['name'], a['pub'], intToCurrency(stakeNet), intToCurrency(stakeCpu), intToCurrency(stakeRam))) util.sleep(1) for i in range(user_limit): a = accounts[i] util.retry( 'cldatx ' + 'push action datxos.token transfer \'["datxos",%s,"%s","vote"]\' -p datxos' % (a['name'], intToCurrency(5000000000000))) util.sleep(1) util.retry('cldatx ' + 'system delegatebw datxos %s "%s" "%s" --transfer' % (a['name'], intToCurrency(300000000000), intToCurrency(350000000000))) util.sleep(1) util.run( 'cldatx ' + 'push action datxos.dtoke transfer \'{"from":"datxos.dbtc","to":"alice","quantity":"300.0000 DBTC","memo":"test"}\' -p datxos.dbtc' ) util.run( 'cldatx ' + 'push action datxos.dtoke transfer \'{"from":"datxos.deth","to":"alice","quantity":"300.0000 DETH","memo":"test"}\' -p datxos.deth' ) util.run( 'cldatx ' + 'push action datxos.dtoke transfer \'{"from":"datxos.deos","to":"alice","quantity":"300.0000 DEOS","memo":"test"}\' -p datxos.deos' )
def _workout_step(self, was_office_hours, is_office_hours): if is_office_hours: # Clear the previous day's history if this is the first workout of the day if not was_office_hours: self.user_manager.clear_users() # Get an exercise to do exercise, reps, mins_to_exercise = self.bot.select_exercise_and_start_time() util.sleep(minutes=mins_to_exercise) # Assign the exercise to someone self.bot.assign_exercise(exercise, reps) else: # Show some stats if the final workout has just passed if was_office_hours: self.slack_api.post_flex_message(self.user_manager.stats()) # Sleep for a bit if not self.configuration.debug(): util.sleep(minutes=5) # Sleep 5 minutes else: # If debugging, check again in 5 seconds util.sleep(seconds=5)
def run(self): self.running = True while self.running: yield sleep(5)
def stepStartBoot(): startNode({'name': 'datxos', 'pvt': private_key, 'pub': public_key}) util.sleep(1.5)
def test_sleep(): now = datetime.datetime.now() yield util.sleep(1) delta = datetime.datetime.now() - now assert delta.seconds == 1
def arena_try(): global limit global wait_hr global wait_day if status.get_money() < 5: return cur_day = int(datetime.datetime.utcnow().strftime('%d')) time = datetime.datetime.time(datetime.datetime.utcnow()) # Check if arena was reset if time.hour == 10 and time.minute < 10 and cur_day != wait_day: limit = False wait_day = cur_day # If arena is over for today, do nothing if limit: return # Arena is closed for night if util.get_day_time(time) == util.day_time.NIGHT: return # If we have no money, wait for next hour if wait_hr == time.hour: return util.sleep(random.randrange(0, 1200)) telega.send_command('🗺Квесты') message = telega.last_msg() if '📯Арена 🔒' in message.message: limit = True return if message.button_count < 4: return telega.click(message, 4, "📯Арена") message = telega.last_msg() if 'Ты сейчас занят другим приключением' in message.message: util.sleep(300) return if not 'Пыльный воздух пропитан густым приторным' in message.message: return if '5/5' in message.message: # It's over for today limit = True else: for i in range(0, 5): util.sleep(5) telega.send_command('▶️Быстрый бой') arena_wait() message = telega.last_msg() hp = status.get_hp() if 'У тебя нет денег' in message.message or 'Тебе бы подлечиться.' in message.message or hp < 100: wait_hr = time.hour return if 'Даже драконы не могут' in message.message: limit = True return
def StartWallet(): util.run('rm -rf ~/datxos-wallet') util.run('mkdir -p ~/datxos-wallet') util.sleep(3) util.run('cldatx ' + 'wallet create --file ~/datxos-wallet/password.ini')
def KillAll(): util.run('killall kdatxd noddatx || true') util.sleep(1.5)
def sell(self): util.screen_shot(self.hwnd, self.name) x, y = util.get_location('temp\\' + self.name + '\\screenshot.png', 'sell.png') if x == 760: util.click_pos(self.hwnd, x, y) util.sleep(1000) for i in range(0, 7): util.click_pos(self.hwnd, 109 + i * 177, 245) util.sleep(300) for i in range(0, 7): util.click_pos(self.hwnd, 109 + i * 177, 422) util.sleep(300) util.sleep(1000) util.click_pos(self.hwnd, 1176, 685) util.sleep(1000) util.click_pos(self.hwnd, 781, 540) util.sleep(1000) util.click_pos(self.hwnd, 516, 456)
def stepVote(): vote(0, 0 + args.num_voters) sleep(1) listProducers() sleep(5)
def sleep(self, tm): self.delayed_call = sleep(SLEEP_TIME) yield self.delayed_call self.delayed_call = None
def _wait(self,hook): while hook(): util.sleep()
def stepStartProducers(): startProducers(firstProducer, firstProducer + numProducers) sleep(args.producer_sync_delay)
def main(): util.start_timetest() util.print_elapsed_time() util.printlog('abc') util.sleep(0.1) util.printlog() util.printlog('xyz') util.sleep(0.2) util.printlog('1234567890') util.sleep(3) util.printlog() util.print_elapsed_time() util.sleep(1) util.print_elapsed_time('Elapsed: ') util.sleep(0.5) util.print_elapsed_time(suffix=' has passed') util.sleep(0.5) util.print_elapsed_time('It took ', ' to process') util.printlog('Done')
def stepRegProducers(): regProducers(firstProducer, firstProducer + numProducers) sleep(1) listProducers()
def KillNoddatx(): util.run('killall noddatx || true') util.sleep(1.5)
def SetSystemContract(): util.retry('cldatx ' + 'set contract datxos ' + contracts_dir + 'DatxSystem/ -x 3500') util.sleep(1) util.run('cldatx ' + 'push action datxos setpriv' + util.jsonArg(['datxos.msig', 1]) + '-p datxos@active')