def display(): ''' Display the introduction screen of application ''' root.destroy() #import login login.main()
def menu (): while True: print("-----------------") area_tmp = [] for i in china_map.china_map.keys():#keys列表返回字典所有的key print(i) area_tmp.append(i) area = input("输入区域:") for a in range(len(area_tmp)): if area in area_tmp: provice_tmp = [] for i in (china_map.china_map.get(area).keys()):#get 返回指定键的值 provice_tmp.append(i) for i in provice_tmp: print(i) provice = input("输入省份:") if provice in provice_tmp: for i in (china_map.china_map.get(area).get(provice)): print(i) inp1 = input("Q:返回上一级/E:退出程序") if inp1 == "Q": continue elif inp1 == "E": login.main() break else: continue
def wait_response(url): sleep_lengh = 30 response = None while True: # todo:不显示为一行的问题 wait_process_bar = tqdm(total=sleep_lengh, ncols=75) wait_process_bar.set_description('等待{}秒'.format(sleep_lengh)) for i in range(sleep_lengh): time.sleep(1) wait_process_bar.update(1) wait_process_bar.close() try: response = requests.get(url=url, headers=login.headers, verify=False) except Exception as e: print('requests Exception:{}'.format(e)) if response.ok: print('获取成功。response.ok:{}'.format(response.ok)) break else: print('response.ok:{}'.format(response.ok)) if sleep_lengh > 60: # 等待时长大于 60 秒时尝试验证或登录 msg = response.json() error = msg['error'] if not error['need_login'] and error['redirect']: print('需要验证。') login.main() elif error['need_login'] and error['redirect']: print('需要登录。') login.main() sleep_lengh += 30 return response
def indexinicio(): email = request.form['email'] password = request.form['pass'] r = requests.get('http://192.168.0.105:5001/get/emails') email_dic = r.content email_json = json.loads(email_dic) emails = [] www = '' for i in range(len(email_json)): split_mail = str(email_json.get(str(i))) list_mail = split_mail.split('\'') emails.append(list_mail[1]) if email not in emails: www += "<body>" + login.main() + "</body>" else: json_mail = {'email': email} ru = requests.post('http://192.168.0.105:5001/get/usuario', json=json_mail) user_dic = ru.content user_json = json.loads(user_dic) passwordDB = user_json.get('password') if password == passwordDB: www = "<body>" + head(email) + inicio.main(email) + "</body>" else: www += "<body>" + login.main() + "</body>" return www
def back(self): login.main() #main()
def start(self): self.progress["value"] = 0 self.maxbytes = 50000 self.progress["maximum"] = 50000 self.read_bytes() if self.progress["value"] == 60000: self.parent.destroy() if self.parent.destroy: import login login.main()
def user(user): while True: print "************* Welcome to User Console *****************" print "" print "Welcome User :"******"" print "1.Start Compliance Check " print "2.Exit to Login again " choice = raw_input(" Enter your choice : ") if choice == "1": initiate.main() elif choice == "2": login.main()
def main(update_seed_num, username, password): LEN_OF_GET_TORRENT = update_seed_num NAME_OF_SAVE_TORRENT = "torrent_tmp" ###文件名、下载数这种全局变量放在前面,调整起来方便 if os.path.exists(NAME_OF_SAVE_TORRENT) == False: os.makedirs(NAME_OF_SAVE_TORRENT) ###创建文件夹 with open('torrent_information.csv', 'w', encoding='utf-8-sig', newline='') as csvfile: torrentwriter = csv.writer(csvfile, dialect='excel') torrentwriter.writerow(['rank'] + ['seed_name'] + ['link'] + ['torrent_name'] + ['price'] + ['reviews'] + ['life'] + ['size'] + ['seeders'] + ['downloaders'] + ['finished_num'] + ['updowner']) cookie = login.main('https://bt.byr.cn/torrents.php?pktype=1', username, password) response = requests.get('https://bt.byr.cn/torrents.php?pktype=1', cookies=cookie) res = response.content num1 = LEN_OF_GET_TORRENT // 50 num2 = LEN_OF_GET_TORRENT % 50 ###LEN_OF_GET_TORRENT写明爬取总数目,num1控制翻页 ,num2控制当页下的条数 for i in range(0, num1 + 1): url = 'https://bt.byr.cn/torrents.php?inclbookmarked=0&pktype=1&incldead=0&spstate=0&page=' + str( i) ###翻页 response1 = requests.get(url, cookies=cookie) res1 = response1.content for j in range(1, 51): if i == num1 and j == num2 + 1: break ###当页下的条数 k = i * 50 + j torrent_xpath = xpath(j) torrent_charge = charge(res1, torrent_xpath) torrent_name = name(res1, torrent_xpath) torrent_name = torrent_name.replace('/', ',') ###每次命名结束都重新替换 torrent_url = get_downloadlink(res1, torrent_xpath) torrent_dl_name = intro(res1, torrent_xpath, cookie) download(torrent_dl_name, torrent_url, cookie, NAME_OF_SAVE_TORRENT) torrent_comments = comments(res1, torrent_xpath) torrent_livetime = livetime(res1, torrent_xpath) torrent_size = size(res1, torrent_xpath).replace(',', '') torrent_seeders = seeders(res1, torrent_xpath).replace(',', '') torrent_leechers = leechers(res1, torrent_xpath) torrent_snatched = snatched(res1, torrent_xpath).replace(',', '') torrent_publisher = publisher(res1, torrent_xpath) torrentwriter.writerow([k] + [torrent_name] + [torrent_url] + [torrent_dl_name] + [torrent_charge] + [torrent_comments] + [torrent_livetime] + [torrent_size] + [torrent_seeders] + [torrent_leechers] + [torrent_snatched] + [torrent_publisher]) if i == num1 and j == num2 + 1: break
def request1(host=hostname): # definitions global hostid # get sessionid token = login.main() # request content post_data = { "jsonrpc": "2.0", "method": "host.get", "params": { "filter": { "host": [host] }, "output": ["hostid", "host"], "selectInterfaces": ["interfaceid", "ip"] }, "id": 2, "auth": token } r = requests.post(url, json=post_data, verify=False) zabbix_ret = r.json() if not zabbix_ret.__contains__('result'): print('Request 2 image creates error:', zabbix_ret.get('error')['data']) else: hostid = zabbix_ret['result'][0]['hostid'] print('login succeeds. Your host is', zabbix_ret['result'][0]['host'], 'with ID of ', hostid, '. IP address of interfaces is', zabbix_ret['result'][0]['interfaces'][0]['ip'])
def request3(): # definitions global evnimageid # get sessionid token = login.main(user, password, url) # request content post_data = { "jsonrpc": "2.0", "method": "image.create", "params": { "imagetype": 2, # type of background image "name": "EVN global map", "image": image2000_1000 }, "auth": token, "id": 4 } r = requests.post(url, json=post_data, verify=False) zabbix_ret = r.json() if not zabbix_ret.__contains__('result'): print("Request 3 image creates error:", zabbix_ret.get('error')['data']) else: evnimageid = zabbix_ret.get('result')['imageids'][0] print("Global map image created successfully") print("Request 3 result: ", zabbix_ret)
def login(): while True: userinfo = main() passt = check.check(userinfo['Gn'], userinfo['Gp'], userinfo['Un'], userinfo['Up']) if passt: break
def post(self): event = request.get_json() response = login.main(event, {}) if response['status'] == 'failed': return response, 401, {'Content-Type': 'text/plain; charset=utf-8'} else: return response, 200, {'Content-Type': 'text/plain; charset=utf-8'}
def post(self): event = { 'username': request.args.get('username'), 'password': request.args.get('password'), } response = login.main(event, {}) return response, 200, {'Content-Type': 'text/plain; charset=utf-8'}
def user(user): ''' This function creates the options for the user. The user can only run the compliance test. ''' while True: print "************* Welcome to User Console *****************" print "" print "Welcome User :"******"" print "1.Start Compliance Check " print "2.Exit to Login again " choice = raw_input(" Enter your choice : ") if choice == "1": initiate.main() elif choice == "2": login.main()
def admin(user): ''' This function creates the options for the user and the admin. Only the unetwork admin can see the existing user details or even add/delete users and even run the compliance test. ''' while True: print "************ Welcome to Admin Console *****************" print "" print "Welcome Admin :"+user print "" print " 1. View Existing Users " print " 2. Add New Users" print " 3. Delete Existing Users" print " 4. View Available Templates" print " 5. Start Compliance Check " print " 6. Exit to Login again " choice = raw_input(" Enter your choice : ") if choice == "1": database_creator.view() elif choice == "2": user = raw_input(" Username: "******" Password: "******" Role(admin/user): ") database_creator.insert(user,password,role) elif choice == "3": user = raw_input(" Username: "******" Role(admin/user): ") database_creator.delete(user,role) elif choice == "4": database_creator.list_dir() elif choice == "5": initiate.main() elif choice == "6": login.main()
def check_user(self): """ 检查用户是否达到订票条件 :return: """ check_user_url = 'https://kyfw.12306.cn/otn/login/checkUser' data = dict(_json_att=None) check_user = json.loads(myurllib2.Post(check_user_url, data), encoding='utf-8') check_user_flag = check_user['data']['flag'] if check_user_flag is True: print('用户有效') return True else: if check_user['messages']: print('用户检查失败:%s,可能未登录,可能session已经失效' % check_user['messages'][0]) else: print('用户检查失败: %s,可能未登录,可能session已经失效' % check_user) print('开始尝试重新登录') login.main()
def guide(self): if (self.setPwd == 'True'): adapter.waitandClick('//*[@id="Start"]') adapter.waitandSendkeys('//*[@id="PwdNew"]', self.login_pwd) adapter.waitandSendkeys('//*[@id="PwdCfm"]', self.login_pwd) adapter.waitandClick('//*[@id="Save"]') time.sleep(1) else: login.main(loginData.login_data_1) #adapter.waitforDisplay('//*[@id="Pop"]') adapter.waitforDisappear('//*[@id="Pop"]') adapter.waitandClick('//*[@id="WanType"]/span') if self.network_mode == 'dhcp': adapter.waitandClick('//*[@id="sel-opts-ulWanType"]/li[1]') elif self.network_mode == 'pppoe': adapter.waitandClick('//*[@id="sel-opts-ulWanType"]/li[2]') adapter.waitandSendkeys('//*[@id="PppoeUser"]', self.pppoeUser) adapter.waitandSendkeys('//*[@id="PppoePwd"]', self.pppoePwd) elif self.network_mode == 'static': adapter.waitandClick('//*[@id="sel-opts-ulWanType"]/li[3]') adapter.waitandSendkeys('//*[@id="WanIpaddr"]', self.ip) adapter.waitandSendkeys('//*[@id="WanMask"]', self.subMask) adapter.waitandSendkeys('//*[@id="WanGw"]', self.gateway) adapter.waitandSendkeys('//*[@id="PrimDns"]', self.dns1) else: print("please input right mode: dhcp, pppoe, static") log.writeadapterErrToLog('guide', 'input data error') #adapter.waitandClick('//*[@id="Save"]') adapter.waitforDisappear('//*[@id="Pop"]') adapter.waitandSendkeys('//*[@id="Ssid2G"]', self.ssid_24G) adapter.waitandSendkeys('//*[@id="Pwd2G"]', self.pwd_24G) adapter.waitandSendkeys('//*[@id="Ssid5G"]', self.ssid_5G) adapter.waitandSendkeys('//*[@id="Pwd5G"]', self.pwd_5G) adapter.waitandClick('//*[@id="SaveReboot"]')
def admin(user): ''' This function creates the ''' while True: print "************ Welcome to Admin Console *****************" print "" print "Welcome Admin :"+user print "" print " 1. View Existing Users " print " 2. Add New Users" print " 3. Delete Existing Users" print " 4. View Available Templates" print " 5. Exit to Login again " choice = raw_input(" Enter your choice : ") if choice == "1": database_creator.view() elif choice == "2": user = raw_input(" Username: "******" Password: "******" Role(admin/user): ") database_creator.insert(user,password,role) elif choice == "3": user = raw_input(" Username: "******" Role(admin/user): ") database_creator.delete(user,role) elif choice == "4": database_creator.list_dir() elif choice == "5": login.main()
def main(path): # 模拟登陆 browser = login.main() # 读取excel文件想要搜索的关键词 seachKeys = fetchKeywords.main() # 循环返回主页 # 查找搜索按钮 # 传入词组批量爬取 search.main(browser, seachKeys, path) return
def main(): while True: os.system("clear") imlec, db = veri_tabani() print(""" DEMIR Hastane Otomasyonu 1-) Personel girişi 2-) Yeni personel ekle Q-) Çıkış """) secim = input("\n Seçim = ") if secim == "1": kontrol = login.kullanici_giris(imlec, db) if kontrol == 1: login.main(imlec, db) if secim == "2": login.kullanici_ekle(imlec, db) if secim == "q" or secim == "Q": quit()
def indexinicioR(): try: nombre = request.form['nombre'] apellidos = request.form['apellidos'] email = request.form['email'] password = request.form['pass'] repass = request.form['repass'] if password == repass: json_usuario = { 'nombre': nombre, 'apellidos': apellidos, 'email': email, 'password': password } requests.post('http://192.168.0.105:5001/post/usuario', json=json_usuario) www = "<body>" + head(email) + inicio.main(email) + "</body>" else: www = "<body>" + login.main() + "</body>" return www except: www = "<body>" + login.main() + "</body>" return www
def request6(mapid=wettzellmapid): # get sessionid token = login.main(user, password, url) # request content post_data = { "jsonrpc": "2.0", "method": "map.delete", "params": [ mapid # here is the id of map to be deleted ], "auth": token, "id": 7 } r = requests.post(url, json=post_data, verify=False) zabbix_ret = r.json() if not zabbix_ret.__contains__('result'): print("Request 6 map deletes error:", zabbix_ret.get('error')['data']) else: print("Wettzell map deleted successfully") print("Request 6 result: ", zabbix_ret)
def request9(mapid=evnmapid): # get sessionid token = login.main(user, password, url) # request content post_data = { "jsonrpc": "2.0", "method": "map.delete", "params": [ mapid # here is the id of maps to delete, refined later ], "auth": token, "id": 10 } r = requests.post(url, json=post_data, verify=False) zabbix_ret = r.json() if not zabbix_ret.__contains__('result'): print("Request 9 map deletes error:", zabbix_ret.get('error')['data']) else: print("EVN global map deleted successfully") print("Request 9 result: ", zabbix_ret)
#!/usr/bin/env python # Este último script se encarga de meter los datos finalmente de la forma que queremos en la base de datos de mediawiki # usando la librería pywikipedia. Este proceso puede resultar muy lento por una limitación de la API aunque se hackeable. import login import wikipedia import os login.main() site = wikipedia.getSite() start_from = "2704_1282534026" revs_dir = "2704" rev_files = os.listdir(revs_dir) i = 0 while rev_files[0] != start_from: rev_files = rev_files[1:] i += 1 for r in rev_files: page = wikipedia.Page(site, "Recortes") rev_file = os.path.join(revs_dir, r) fd = open(os.path.join(rev_file)) txt = unicode(fd.read()) fd.close() print "Writing rev number", r page.put(txt)
def main(): auth = login.main() targets = accountNames makeFolders(targets)
import books_api as books # import book # import book_support import tkinter import entrysmall import input import entry import sql import homepage import json import misc_python import login if __name__ == "__main__": login.main()
def indexlogin(): www = "<body>" + login.main() + "</body>" return www
def open_login_screen(root): root.destroy() ld.main()
import os import pandas as pd import time import tweepy import login auth = login.main() api = tweepy.API(auth) ''' get id and account name of actual tweet target = 'Cernovich' statusID = '1311904974532567040' ''' rootPath = '/home/jean/Documents/rescueDemocracy2020' def reply(replyText, originalReTweet): fullText = '@' + originalReTweet.user.screen_name + replyText try: t = api.update_status(status=fullText, in_reply_to_status_id=originalReTweet.id, auto_populate_reply_metadata=True) print('sucess with: ' + originalReTweet.user.screen_name) #completed(originalReTweet.user.screen_name) return True except: print('failed with: ' + originalReTweet.user.screen_name) return False time.sleep(15)
# client.py import pygame from network import Network import pickle import json import login user_id, score = login.main() score = int(score) pygame.mixer.init() pygame.font.init() width = 700 height = 700 soundWin = pygame.mixer.Sound("sound/win.mp3") soundTie = pygame.mixer.Sound("sound/tie.wav") soundLost = pygame.mixer.Sound("sound/lost.ogg") win = pygame.display.set_mode((width, height)) pygame.display.set_caption("Client") class Button: def __init__(self, text, x, y, color): self.text = text self.x = x self.y = y self.color = color self.width = 150 self.height = 100
def main(): '''Call the function you with to test that needs there vars set''' login.main()