def case_info(request): usr = auth.Auth().getUsr(request) platformId = '1' searchText = '' searchType = 0 pageNum = 1 if 'platformId' in request.GET: platformId = request.GET['platformId'] if 'pageNum' in request.GET: pageNum = request.GET['pageNum'] if 'searchText' in request.GET: platformId = request.GET['platformId'] searchType = request.GET['searchType'] searchText = request.GET['searchText'] if searchType == '0': testCases = TESTCASE.objects.filter(PLATFORM_ID_id=platformId,Testsuit_name__icontains=searchText,status=0).order_by("id") elif searchType == '1': testCases = TESTCASE.objects.filter(PLATFORM_ID_id=platformId,case_name__icontains=searchText,status=0).order_by("id") else: testCases = TESTCASE.objects.filter(PLATFORM_ID_id=platformId,status=0).order_by("id") numInPage = 15 paginator = Paginator(testCases, numInPage) testCase = paginator.page(pageNum) totalPage = len(testCases)/numInPage + 1 if 'part' in request.GET: return render_to_response('dateapp/case_info_table.html',locals()) else: return render_to_response('dateapp/case_info.html',locals())
def cal(): """ Checks authorization of user to request ical file """ # email, firstname, lastname = get_profile() # if email and firstname and lastname and check_choate_email(email): # log.info("here") token = request.args.get('token') email = request.args.get('email') firstname = request.args.get('first') lastname = request.args.get('last') authentication = auth.Auth() authentication.init_db_connection() email = authentication.get_email_from_token(token) authentication.end_db_connection() if email: cal = make_response( make_calendar(email, firstname, lastname).to_ical()) cal.mimetype = 'text/calendar' return cal return redirect('/')
def setUp(self): # Call Parent super(BaseTestCase, self).setUp() # Setup Server self.auth = auth.Auth()
def fetch_data(): try: if not authentication.is_expired(session["access_token"]): import vgmdb authentication = auth.Auth() vgm_fetcher = vgmdb.VGMDB() vgmdb_album_id = request.args.get("vgmdb_album_id") vgmdb_filters = request.args.get("vgmdb_filters") tracklist = vgm_fetcher.get_tracklist(vgmdb_album_id, vgmdb_filters) return jsonify({ "success": True, "tracklist": tracklist, "message": "Success to fetch data from VGMDB" }) except KeyError as exception: print(exception) return jsonify({"success": False, "message": "Login first"}), 400 except Exception as exception: print(exception) return jsonify({ "success": False, "message": "Contact our administrator!" }), 500 finally: authentication = None
def reload_auth(self): try: reload(auth) ibid.auth = auth.Auth() self.log.info(u'Reloaded auth') return True except Exception, e: self.log.error(u"Couldn't reload auth: %s", unicode(e))
def setUp(self): self.path = tempfile.mkdtemp() os.chmod(self.path, 0700) self.auth = auth.Auth(self.path) self.auth_token = 'a3d9e77af80187d548e36a2d597005e3f23fab16' expiry = int(time.time()) + 86400 with open(os.path.join(self.path, 'auth_token'), 'w') as f: f.write("%s %d" % (self.auth_token, expiry)) os.environ.clear()
def task_report(request): task_result = {"0": "PASS", "1": "FAIL", "2": "NEW"} if not auth.Auth().isLogin(request): return HttpResponseRedirect('/login') else: usr = auth.Auth().getUsr(request) if 'taskId' in request.GET: taskId = request.GET['taskId'] newestTask = Task.objects.get(id="%s" % taskId) else: newestTask = Task.objects.filter(LDAP=usr).order_by('-id')[0] taskId = newestTask.id resList = TASKRESULT.objects.filter(task_id="%s" % taskId) #for i in resultList: #res.append('<tr><td>%s</td></tr>') % (resultList.suiteId) return render_to_response('dateapp/task_report.html', locals())
def run(): url = 'https://www.douban.com/group/252218/' (account, password) = auth.Auth.parse_conf() if not account or not password: print 'input account and password!' douban = auth.Auth(account, password) douban.login() result = douban.url_get(url) douban.test_result(result)
def show (request): au = auth.Auth(request) order_list = show_order(au,request) template = loader.get_template('market/order.html') context = { 'auth_list': au.get_list(), 'order_list': order_list } return HttpResponse(template.render(context, request))
def show(request): au = auth.Auth(request) bsk = basket.Bsk(au, request) bsk.update_bsk(request) template = loader.get_template('market/basket.html') context = { 'auth_list': au.get_list(), 'dish_list': bsk.dish_list(), 'restaurant': bsk.restaurant(), } return HttpResponse(template.render(context, request))
def __init__(self, auth_flag=False): self.base_url = 'https://www.douban.com/group/topic/' self.auth_flag = auth_flag self.post_db = douban_db['post'] if self.auth_flag: (account, password) = auth.Auth.parse_conf() if not account or not password: print 'input account and password!' self.douban_login = auth.Auth(account, password) self.douban_login.login() else: self.douban_login = None
def cal(): email, firstname, lastname = get_profile() if email and firstname and lastname and check_choate_email(email): log.info("here") token = request.args.get('token') authentication = auth.Auth() if authentication.check_token(email, token): cal = make_response(make_calendar(email, firstname, lastname).to_ical()) cal.mimetype = 'text/calendar' return cal return redirect('/')
def show(request, rest_id): au = auth.Auth(request) bsk = basket.Bsk(au, request) bsk.add_2basket(request) rest = Restaurant.objects.get(pk=rest_id) menu_list = Dish.objects.filter(restaurant=rest_id) template = loader.get_template('market/menus.html') context = { 'auth_list': au.get_list(), 'menu_list': menu_list, 'restaurant': rest, } return HttpResponse(template.render(context, request))
def charge_data(): latitude = '' longitude = '' try: latitude = request.args.get('latitude') longitude = request.args.get('longitude') except: return { 'code': 400, 'message': 'Missing latitude and longitude arguments at the call.' }, 400 auth_object = auth.Auth(secrets['key'], secrets['secret']) auth_json = auth_object.auth() bearer = auth_json['access_token'] print(bearer) contador = 1 FILE = csv.writer(open('./Data/data_01.csv', 'a')) FILE.writerow([ 'ID', 'LATITUD', 'LONGITUD', 'TAMAÑO', 'PRECIO AL MES', 'RELACION PRECIO TAMAÑO' ]) while contador <= int(request.args.get('numPags')): data = ide.get_properties(bearer, 'rent', latitude, longitude, contador) if data == False: return {'code': 200, 'message': 'All available data charged'}, 200 for property in data['elementList']: new_row = [ property['propertyCode'], property['latitude'], property['longitude'], property['size'], property['price'], property['priceByArea'] ] FILE.writerow(new_row) contador += 1 FILE.close() #Limpiamos lineas en blanco with open('./Data/data_01.csv') as infile, open('./Data/data_01.csv', 'w') as outfile: for line in infile: if not line.strip(): continue # skip the empty line outfile.write(line) # non-empty line. Write it to output return {'code': 200, 'message': 'Data charged :D'}, 200
def env_check(request): if not auth.Auth().isLogin(request): return HttpResponseRedirect('/login') else: usr = auth.Auth().getUsr(request) if 'platformId' in request.GET: platformId = request.GET['platformId'] else: platformId = 1 env_status = { "0": "Create", "1": "RunOn", "2": "Run", "3": "Fail", "4": "StopOn", "5": "Stop", "6": "Del", "7": "DelOn" } if 'modify' in request.GET: envId = request.GET['envId'] op = request.GET['op'] env = ENV.objects.get(ENV_ID=envId) platformId = env.PLATFORM_ID_id handleOp(op, env) envList = ENV.objects.filter( LDAP=usr, PLATFORM_ID_id=platformId).exclude(STATUS=6).order_by("-ENV_ID") if 'platformId' in request.GET or 'modify' in request.GET: return render_to_response( 'dateapp/env_check_table.html', locals()) #,{'taskset':taskset,'tasknum':tasknum} else: return render_to_response('dateapp/env_check.html', locals())
def task_history(request): usr = auth.Auth().getUsr(request) taskResult = {"0": "PASS", "1": "FAIL", "2": "DEFAULT"} if 'platformId' in request.GET: platformId = request.GET['platformId'] else: platformId = 1 taskList = Task.objects.filter(STATUS=3, PLATFORM_ID_id=platformId).order_by("-id") if 'platformId' in request.GET: return render_to_response('dateapp/task_history_table.html', locals()) else: return render_to_response('dateapp/task_history.html', locals())
def setUp(self): # Call Parent super(BuilderTestCase, self).setUp() # Setup Auth self.auth = auth.Auth() # Setup Server self.srv = structs.Server() # Create User self.user = self.auth.create_user(test_common.USER_TESTDICT, username="******", password="******", authmod="test")
def show(request): au = auth.Auth(request) if 'q' in request.GET: #sql inject restaurants_list = Restaurant.objects.filter( dish__name__icontains=request.GET['q']).annotate( meal=Count('dish')) elif 'g' in request.GET: point = address2latlng(request.GET['g']) restaurants_list = get_restaurants_near_latlng(g['lat'], g['lng']) else: restaurants_list = Restaurant.objects.all() template = loader.get_template('market/restaurants.html') context = { 'auth_list': au.get_list(), 'restaurants_list': restaurants_list, } return HttpResponse(template.render(context, request))
def authentication(): if request.method == "POST": username = request.form.get("leecher_username") password = request.form.get("leecher_password") authentication = auth.Auth() token = authentication.login_auth(username, password) session["access_token"] = token["access_token"] authentication = None if token["access_token"] != "": del token["access_token"] return jsonify({ "success": True, "message": "Welcome " + token["username"] }) return jsonify({ "success": False, "message": "Failed to authenticate user" })
def main(): """Checks for a matching username/password combination, then fill the openfoodfacts database. """ parser = argparse.ArgumentParser() my_auth = auth.Auth() parser.add_argument("user", help="is the user for the database") args = parser.parse_args() my_auth.user = args.user my_auth.password = getpass.getpass() try: my_connection = mysql.connector.connect(user=my_auth.user, password=my_auth.password, database='openfoodfacts') my_connection.close() dt = datacollecter.DataCollecter(my_auth) my_data = dt.my_data fil = filler.Filler(my_data, my_auth) fil.put_it_in_tables() except mysql.connector.errors.ProgrammingError: print( "This user/password combination doesn't exist! Try another combination." )
def logout(): try: authentication = auth.Auth() if authentication.is_expired(session["access_token"]): return jsonify({ "success": True, "message": "Your session has been expired" }) session.pop("access_token", None) return jsonify({ "success": True, "message": "User has been logged out" }) except KeyError as exception: print(exception) return jsonify({ "success": False, "message": "User not login to the app yet" }), 400 finally: authentication = None
def testAuthInitFail(self, input): with pytest.raises(TypeError): newAuth = auth.Auth(input)
def start_task(request): try: if request.is_ajax(): if request.method == "POST": impr_svn = request.POST.get('item1', None) resin_svn = request.POST.get('item2', None) testsuit = request.POST.get('item3', None) platform = request.POST.get('tag', None) usr = auth.Auth().getUsr(request) timenow = time.time() if platform == "Union": PLATFORM = Platform.objects.filter(PLATFORM_NAME="eadu") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) #LOG_PATH,USER_CASES,TIME需要改,LDAP需要在机群上调试 elif platform == "Dict": PLATFORM = Platform.objects.filter(PLATFORM_NAME="eadd") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) elif platform == "Mail": PLATFORM = Platform.objects.filter(PLATFORM_NAME="eadm") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) elif platform == "Channel": PLATFORM = Platform.objects.filter(PLATFORM_NAME="eadc") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) elif platform == "Dspbs": PLATFORM = Platform.objects.filter(PLATFORM_NAME="dsp") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) elif platform == "Convtrack": PLATFORM = Platform.objects.filter( PLATFORM_NAME="convtrack") env = ENV.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", IMPR_SVN=impr_svn, RESIN_SVN=resin_svn, IMPR_PORT="0", RESIN_PORT="1", EMMA_PORT="1") task = Task.objects.create(PLATFORM_ID=PLATFORM[0], LDAP=usr, TIME=timenow, STATUS="0", RESULT="2", LOG_PATH="TEST", ENV_ID=env, USER_CASES=testsuit) return HttpResponse(json.dumps({ "status": "success", "taskid": task.id }), mimetype='application/json') else: pass except Exception, ex: pass
import auth as A import dashboard as D print( "################################### HELLO :) #####################################" ) Auth = A.Auth() Is_LoggedBefore = Auth.isLogged() if Is_LoggedBefore == False: input_user_email = input("Your Email: ") print("Nice to meet you " + str(input_user_email)) input_user_password = input("Insert your pass now: ") print("Your Data:") print("Email:" + str(input_user_email)) print("Password:"******"Proceding to auth ........") Auth = A.Auth(input_user_email, input_user_password) is_logged = Auth.isLogged() if Is_LoggedBefore or is_logged: print( "################################### WELCOME :) ######################################" ) print(" " + Auth.getEmail() + " ") print( "# #"
from __future__ import print_function import io import mimetypes from apiclient import errors from googleapiclient.discovery import build from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload import auth SCOPES = ['https://www.googleapis.com/auth/drive'] # SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] CLIENT_SECRET_FILE = 'credentials.json' APPLICATION_NAME = 'Drive APi Python Quickstart' authInstant = auth.Auth(SCOPES, CLIENT_SECRET_FILE, APPLICATION_NAME) credentials = authInstant.get_credentials() drive_service = build('drive', 'v3', credentials=credentials) def list_files(size): """ List all files of the drive""" results = drive_service.files().list( pageSize=size, fields="nextPageToken, files(id, name, trashed)").execute() items = results.get('files', []) if not items: print('No files found.') else: print('Files:') for item in items: print(u'{0} ({1}) - {2}'.format(item['name'], item['id'],
def case_edit(request): gl.logger.info("***************in case edit *******************") if not auth.Auth().isLogin(request): return HttpResponseRedirect('/login') else: usr = auth.Auth().getUsr(request) matchTypeList = ["exact", "no"] logTypeList = [ "logs/log", "logs/bid-dsp.log", "logs/pv-dsp.log", "logs/impr-dsp.log", "logs/stat.log", "CLICK_TANX", "logs/user-context.log", "logs/new-user-context.log", "CLICK_ADX", "CLICK_BEX", "CLICK_TADE", "CLICK_ALLYES", "IMPR_TANX", "IMPR_ALLYES", "IMPR_TANX_log", "IMPR_ADX_log", "IMPR_ADX", "logs/brand/brandstat.log" ] if 'id' in request.GET: caseId = request.GET['id'] case = TESTCASE.objects.get(id=caseId) platformId = case.PLATFORM_ID_id xmlFile = XMLFILE.objects.filter(platformId_id=platformId) return render_to_response('dateapp/case_edit.html', locals()) if 'save' in request.GET: cases = request.GET['cases'] platformId = request.GET['platformId'] try: saveCases(cases, platformId) except NotImplementedError: return HttpResponse(0) return HttpResponse(1) if 'deleted' in request.GET: cases = request.GET['cases'] deleteId = json.loads(cases) doDelete(deleteId) return HttpResponse(1) if 'add' in request.GET: platformId = request.GET['platformId'] xmlFile = XMLFILE.objects.filter(platformId_id=platformId) return render_to_response('dateapp/case_edit.html', locals()) if 'copy' in request.GET: platformId = request.GET['platformId'] cases = request.GET['cases'] copyId = json.loads(cases) id = doCopy(copyId) return HttpResponse(id) if 'file' in request.GET: file = request.GET['file'] platformId = request.GET['platformId'] try: dealWithFile(file, platformId, usr) except NotImplementedError: return HttpResponse(1) return HttpResponse(0) if 'importXml' in request.GET: platformId = request.GET['platformId'] filePath = request.GET['filePath'] importXmlFile(platformId, filePath, usr) return HttpResponse(0) if 'suiteName' in request.GET: platformId = request.GET['platformId'] suiteName = request.GET['suiteName'] alltestCase = TESTCASE.objects.filter( PLATFORM_ID_id=platformId, Testsuit_name__icontains=suiteName).order_by("-id") elif 'caseName' in request.GET: platformId = request.GET['platformId'] caseName = request.GET['caseName'] alltestCase = TESTCASE.objects.filter( PLATFORM_ID_id=platformId, case_name__icontains=caseName).order_by("-id") else: alltestCase = TESTCASE.objects.filter( PLATFORM_ID_id=platformId).order_by("-id") numInPage = 15 paginator = Paginator(alltestCase, numInPage) testCase = paginator.page(pageNum) xmlFile = XMLFILE.objects.filter(platformId_id=platformId) matchTypeList = ["exact", "no"] caseNum = len(alltestCase) totalPage = len(alltestCase) / numInPage + 1 if 'platformId' in request.GET: return render_to_response('dateapp/case_edit_table.html', locals()) else: return render_to_response('dateapp/case_edit.html', locals())
import user import show import auth import log op = user.User() sh = show.Output() au = auth.Auth() log = log.Log() def logic(): while True: userinfo = input("Please input your action: ") info = userinfo.split() if len(info) == 0: print("input action invalid.") else: action = info[0] if action == "add": # add monkey 12 188*** [email protected] op.add(info[1], info[2], info[3], info[4]) elif action == "delete": # delete monkey op.delete(info[1]) elif action == "update": # update monkey set age = 20 op.update(info[1], info[3], info[-1]) elif action == "list": # list result = op.list()
class ProxyResponse(ProxyBaseResponse): """ 对aiohttp异步和同步返回的结果封装 """ def __init__(self, data, await_data): super(ProxyResponse, self).__init__(data) self.text = await_data['text'] self.read = await_data['read'] if __name__ == '__main__': session = ProxySession() app_key = "xxxxxxxxxxxxxxxxxxxx" myauth = auth.Auth(app_key) # 传入app_key mywandou = wandou.WandouManager(myauth) # 传入myauth url_list = ['http://myip.ipip.net'] * 10 # 需要访问的url列表 proxies = [] proxies.extend([ps for ps in mywandou.proxies(num=10)]) # 获取代理ip列表 url_by_proxy = list(zip(url_list, proxies)) # 每项为url和代理ip的的二元组 print(url_by_proxy) start_time = time.time() result = session.get(url_by_proxy) # 请求。。。受代理ip可靠性和目标网站影响速度 end_time = time.time() tol = end_time - start_time j = 0 for i in result:
# Render manage project template self.write( html_loader.load('admin/project.html').generate( project=projects[project])) except KeyError: # Project not found self.set_status(404) self.write('InvalidProject') # Template loader object html_loader = tornado.template.Loader('templates') projects = {} # Dictionary of project objects auth = auth.Auth() # Authentication object for p in os.listdir('projects'): if p.endswith('.json') and not p.endswith('leaderboard.json'): with open(os.path.join('projects', p), 'r') as jf: # Read project info project_name = json.loads(jf.read())['project-meta']['name'] # Create one project object for every project found projects[project_name] = project.Project(os.path.join('projects', p)) if __name__ == "__main__": PORT = 80 # Set server port # Settings for tornado server
def get_calendar(): email, firstname, lastname = get_profile() if email and firstname and lastname and check_choate_email(email): authentication = auth.Auth() return authentication.fetch_token(email) return False