def test_login(self): print("Testing login") user = common.generate_user() common.make_user(GATEWAY_URL, user) creds = {"email": user["email"], "password": user["password"]} common.login(GATEWAY_URL, creds)
def test_update_resource(self, app, client): _id = self.insert_data().id add_resource(app, Todo) # Request to R.R. Inc endpoint with the same id token = login("RoadRunner", "rrinc", scope={"todo": ["write"]}) rv = client.patch( f"/orgs/rrinc/todo/{_id}", data=dumps({"task": "Do something"}), content_type="application/json", headers={"Authorization": token}, ) assert rv.status_code == 404, ( f"The status code should be 404 because the model id ({_id})" " used in the URL belongs to another organization account.") # Request to Acme endpoint token = login("coyote", "acme", scope={"todo": ["write"]}) rv = client.patch( f"/orgs/acme/todo/{_id}", data=dumps({"task": "Do something"}), content_type="application/json", headers={"Authorization": token}, ) data = rv.get_json() assert rv.status_code == 200 assert "org_id" not in data todo = Todo.query.filter_by(id=_id).one() assert todo.task == "Do something"
def setup_class(cls): cls.driver = common.open_driver(Page_login.url) common.login( cls.driver, yaml.safe_load(open('Test_data.yml', encoding='utf8'))['creat_garbage']) # 等待dialog页面弹出然后关闭他 common.click( common.wait_until_show( cls.driver, Page_garbage.newxpaths['xpath_close_dialog']))
def main(): #pywikibot.verbose = True # turn off cosmetic changes config.cosmetic_changes = False # login with archive bot account sites = [pywikibot.Site(code, family) for code, family in settings.sites] for site in sites: common.login(settings.username, settings.password, site=site) # do work for page in pagesToArchiveGenerator.PagesToArchiveGenerator(sites): pageArchiver = archivePage.PageArchiver(page) pageArchiver.archive()
def main(): ENVIRONMENTS.extend(common.get('/environments').json()) test_table() prepare_users() with ProcessPoolExecutor( max_workers=os.cpu_count(), mp_context=mp.get_context('fork'), ) as executor: try: common.login() run_tests(executor) executor.shutdown(wait=True) finally: common.logout()
def zhaopin_new_search(params, dedup, proxies=None): assert username, password # proxies=None # proxies = {'http': 'http://120.52.72.53:80', 'https': 'http://120.52.72.53:80'} is_login, session = login(username, password, proxies=proxies, logger=logger) if not is_login: logger.warning("登录失败,请重试!") raise Exception("PROXY_FAIL!") url = "http://www.818cv.com/resume/search/" search_params = SpiderSearchUrl(params).splice_search_urls() if "scheme_flag" in params: if "scheme" not in params and "scheme_index" not in params: logger.info("params中包含shceme_flag, 但是没有scheme和scheme_index......") for resume in getResumeMinning( session, url, search_params, dedup=dedup, proxies=proxies).goto_resume_urls_without_scheme(): yield resume else: logger.info("params中包含shceme_flag, 且包含scheme和scheme_index.....") for resume in getResumeMinning( session, url, search_params, dedup=dedup, proxies=proxies).goto_resume_urls_with_scheme(params): yield resume else: logger.info("params中没有shceme_flag.....") for resume in getResumeMinning(session, url, search_params, dedup=dedup, proxies=proxies).goto_resume_urls(): yield resume
def setUpClass(cls): cls.a = login(cls.s) aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberid = aa['body']['memberid'] studentName = test_student_add_resource(cls.s, cls.uri, cls.token, cls.memberid, cls.platform) resourceId1 = test_student_list_status_0(cls.s, cls.uri, cls.token, cls.memberid, cls.platform, studentName)[0] resourceId2 = test_student_update_oversea_program( cls.s, cls.uri, cls.token, cls.memberid, cls.platform, resourceId1) list_info = test_oversea_program_list(cls.s, cls.uri, cls.token, cls.memberid, cls.platform, resourceId2) resourceId3 = list_info[0] schemeId = list_info[1] schemeMemberId = list_info[2] detail_info = test_oversea_program_detail(cls.s, cls.uri, cls.token, cls.memberid, cls.platform, resourceId3, schemeId, schemeMemberId) cls.resourceId = detail_info[0] cls.schemeId = detail_info[1][0] cls.r = detail_info[2][0] cls.f = cls.memberid
def setUpClass(cls): cls.a = login(cls.s) aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] cls.countryId = resource_country_list(cls.s, cls.uri, cls.token, cls.memberId, cls.platform)[0][1]
def create_publications(location): with open(publication_template_file_name) as publication_template_file: publication_template = json.load(publication_template_file) with open(test_publications_file_name) as test_publications_file: test_publications = json.load(test_publications_file) for test_publication in test_publications: username = test_publication['owner'] bearer_token = '' if username in bearer_tokens: bearer_token = bearer_tokens[username] else: bearer_token = common.login(username=username) bearer_tokens[username] = bearer_token new_publication = create_test_publication( publication_template=publication_template, test_publication=test_publication, location=location, bearer_token=bearer_token ) print(test_publication['title']) response = put_item( new_publication=new_publication, bearer_token=bearer_token) identifier = response['identifier'] if test_publication['status'] == 'PUBLISHED': print(f'publishing...{identifier}') response = publish_publication(identifier=identifier, bearer_token=bearer_token) if 'doi' in test_publication: print('requesting doi...') request_doi(identifier=identifier, bearer_token=bearer_token)
def setUpClass(cls): # 初始化会话对象 cls.a = login(cls.s) # 登录用户 aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberid = aa['body']['memberid']
def playGame(): # Authenticate if vars.cookies == '': vars.cookies = common.login() if not vars.cookies: return currentvideo_id = vars.params.get("video_id") currentvideo_type = vars.params.get("video_type") start_time = vars.params.get("start_time") duration = vars.params.get("duration") currentvideo_ishomefeed = vars.params.get("video_ishomefeed", "1") currentvideo_ishomefeed = currentvideo_ishomefeed == "1" # Get the video url. # Authentication is needed over this point! currentvideo = getGameUrl(currentvideo_id, currentvideo_type, currentvideo_ishomefeed, start_time, duration) if 'url' in currentvideo: item = xbmcgui.ListItem(path=currentvideo['url']) if '.mpd' in currentvideo['url']: is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha') if is_helper.check_inputstream(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream.adaptive.manifest_type', 'mpd') item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') item.setContentLookup(False) #TODO: get license url from config licUrl = 'https://prod-lic2widevine.sd-ngp.net/proxy|authorization=bearer ' + currentvideo['drm'] + '|R{SSM}|'; item.setProperty('inputstream.adaptive.license_key', licUrl) xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
def test_get_member_roles_repsonse_payload(self, client): token = login("yosesam", "acme", scope={"org": ["manage"]}) rv = client.get( f"/orgs/acme/members/yosesam/roles/2", headers={"Authorization": token} ) assert rv.status_code == 200
def setUpClass(cls): cls.a = login(cls.s) # 实例化登录对象 aa = cls.a.outside_consultants_login(cls.uri) # 调用外部顾问登录方法并返回用户数据 cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] # 调用国家列表接口获取国家id countryInfo = resource_country_list(cls.s, cls.uri, cls.token, cls.memberId, cls.platform) countryIds = countryInfo[0] countryId = countryIds[1] # 澳洲 # 调用用户保存国家接口获取国家id cls.countryId = member_save_country(cls.s, cls.uri, cls.token, cls.memberId, cls.platform, countryId) # 调用热门院校接口获取院校id schoolIds = school_rank(cls.s, cls.uri, cls.token, cls.memberId, cls.platform, countryId) schoolId = schoolIds[0] # 调用院校详情接口返回memberId persionMemberIds = school_detail(cls.s, cls.uri, cls.token, cls.memberId, cls.platform, countryId, schoolId) cls.persionMemberId = persionMemberIds[0]
def test_add_org_endpoint(req_payload, status_code, client): rv = client.post( "/users/coyote/orgs", data=dumps(req_payload), content_type="application/json", headers={"Authorization": login("coyote")}, ) assert rv.status_code == status_code if rv.status_code == 201: org = ( Org.query.options(joinedload(Org.created_by)) .filter_by(orgname=req_payload["orgname"]) .one() ) member = Membership.query.filter_by( org_id=org.id, user_id=org.created_by.id ).one() assert org.orgname == "choco" assert org.name == "The Chocolate Factory" assert org.created_by.username == "coyote" assert member.is_owner is True
def test_add_role_with_abilities(self, client): token = login("coyote", "acme", scope={"org": ["manage"]}) data = dumps( { "name": "New Role", "description": "...", "abilities": [ {"action_id": 1, "resource_id": 1}, {"action_id": 2, "resource_id": 1}, ], } ) rv = client.post( f"/orgs/acme/roles", headers={"Authorization": token}, data=data, content_type="application/json", ) data = rv.get_json() assert rv.status_code == 201, rv.data assert "org_id" not in data assert "id" in data assert data["name"] == "New Role" assert data["description"] == "..." assert len(data["abilities"]) == 2
def setUpClass(cls): cls.a = login(cls.s) aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] cls.countryId = 12
def test_list_roles(self, client, orgname, expected): token = login("coyote", orgname, scope={"org": ["manage"]}) rv = client.get(f"/orgs/{orgname}/roles", headers={"Authorization": token}) data = rv.get_json() assert rv.status_code == 200 assert len(data) == expected
def test_get_member_roles(self, client, orgname, username, id, expected): token = login(username, orgname, scope={"org": ["manage"]}) rv = client.get( f"/orgs/{orgname}/members/{username}/roles/{id}", headers={"Authorization": token}, ) assert rv.status_code == expected
def test_delete_role(self, client, id, expected): token = login("coyote", "acme", scope={"org": ["manage"]}) rv = client.delete(f"/orgs/acme/roles/{id}", headers={"Authorization": token}) assert rv.status_code == expected rv = client.get(f"/orgs/acme/roles/{id}", headers={"Authorization": token}) assert rv.status_code == 404
def run(): print('publications...') map_user_to_arp() bearer_token = common.login(username='******') location = upload_file(bearer_token=bearer_token) delete_publications() create_publications(location=location)
def test_list_resource(self, client): token = login("coyote", scope={"app": "read"}) rv = client.get("/actions", headers={"Authorization": token}) assert rv.status_code == 200 data = rv.get_json() assert len(data) > 0
def test_delete_plan(client): token = login("coyote", scope={"app": ["delete"]}) url = "/plans/1" rv = client.delete(url, headers={"Authorization": token}) assert rv.status_code == 200 assert client.get(url).status_code == 404
def get_episode_url(start_timestamp, duration, force_login=False): if not vars.cookies or force_login: common.login() if not vars.cookies: return None url = vars.config['publish_endpoint'] headers = { 'Cookie': vars.cookies, 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36', } body = { 'type': 'channel', 'id': 1, 'drmtoken': True, 'deviceid': xbmc.getInfoLabel('Network.MacAddress'), 'st': start_timestamp, 'dur': duration, 'pcid': vars.player_id, 'format': 'xml', } body = urllib.urlencode(body) utils.log('the body of publishpoint request is: %s' % body, xbmc.LOGDEBUG) try: request = urllib2.Request(url, body, headers) response = urllib2.urlopen(request) content = response.read() except urllib2.HTTPError as err: utils.logHttpException(err, url) utils.littleErrorPopup(xbmcaddon.Addon().getLocalizedString(50020)) return None xml = parseString(str(content)) url = xml.getElementsByTagName('path')[0].childNodes[0].nodeValue utils.log('response URL from publishpoint: %s' % url, xbmc.LOGDEBUG) drm = xml.getElementsByTagName('drmToken')[0].childNodes[0].nodeValue utils.log(drm, xbmc.LOGDEBUG) return {'url': url, 'drm': drm}
def setUpClass(cls): cls.a = login(cls.s) aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] cls.smsCode = get_student_detail_sms_template_list( cls.s, cls.uri, cls.token, cls.memberId, cls.platform)[1]
def test_list_abilities(self, client): token = login("coyote", scope={"app": ["read"]}) rv = client.get("/abilities", headers={"Authorization": token}) assert rv.status_code == 200 data = rv.get_json() assert len(data) > 0
def setUpClass(cls): cls.a = login(cls.s) aa = cls.a.outside_consultants_login(cls.uri) cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] inviterInfo = test_student_list_status_0(cls.s, cls.uri, cls.token, cls.memberId, cls.platform) cls.resourceId = inviterInfo[0]
def setUpClass(cls): cls.a = login(cls.s) # 实例化登录对象 aa = cls.a.outside_consultants_login(cls.uri) # 调用外部顾问登录方法并返回用户数据 cls.token = aa['body']['token'] cls.memberId = aa['body']['memberid'] cls.countryInfo = resource_country_list(cls.s, cls.uri, cls.token, cls.memberId, cls.platform) cls.countryIds = cls.countryInfo[0] cls.countryId = cls.countryIds[1] # 澳洲
def test_get_resource(self, client): _id = Action.query.first().id token = login("coyote", scope={"app": "read"}) rv = client.get(f"/actions/{_id}", headers={"Authorization": token}) assert rv.status_code == 200 data = rv.get_json() assert data["id"] == _id
def test_add_role_to_member(self, client): token = login("coyote", "acme", scope={"org": ["manage"]}) rv = client.post( "/orgs/acme/members/yosesam/roles", headers={"Authorization": token}, content_type="application/json", data=dumps({"roles": [1, 3]}), ) assert rv.status_code == 201
def test_delete_resource(self, app, client): _id = self.insert_data().id add_resource(app, Todo) # Request to R.R. Inc. token = login("RoadRunner", "rrinc", scope={"todo": ["delete"]}) headers = {"Authorization": token} rv = client.delete(f"/orgs/rrinc/todo/{_id}", headers=headers) assert rv.status_code == 404, ( f"The status code should be 404 because the model id ({_id})" " used in the URL belongs to another organization account.") # Request to Acme token = login("coyote", "acme", scope={"todo": ["delete"]}) headers = {"Authorization": token} rv = client.delete(f"/orgs/acme/todo/{_id}", headers=headers) assert rv.status_code == 200 assert Todo.query.get(_id) is None
def test_list_resource(self, app, client): _id = self.insert_data().id add_resource(app, Todo) # Request to Acme endpoint token = login("coyote", "acme", scope={"todo": ["read"]}) rv = client.get(f"/orgs/acme/todo", headers={"Authorization": token}) data = rv.get_json() assert rv.status_code == 200 assert data[0]["id"] == _id assert "org_id" not in data[0] # Request to R.R. Inc endpoint token = login("RoadRunner", "rrinc", scope={"todo": ["read"]}) rv = client.get(f"/orgs/rrinc/todo", headers={"Authorization": token}) data = rv.get_json() assert rv.status_code == 200 assert len(data) == 0
choice = 'y' if not acceptAll: choice = pywikibot.inputChoice( u'Do you want to accept these changes?', ['Yes', 'No', 'All', 'Quit'], ['y', 'N', 'a', 'q'], 'N') if choice == 'q': exit() if choice == 'a': acceptAll = True choice = 'y' if choice == 'y': self.page.put(newText, editSummary) pass def run(self): self.addZeroSection() # main code if __name__ == '__main__': common.login(username) talkPages = pagegenerators.AllpagesPageGenerator(namespace = 1, includeredirects = False, site = common.getWikiSite()) #talkPages = [pywikibot.Page(site = dxdCommonLibrary.getWikiSite() ,title = u'Обговорення користувача:RLuts')] talkPages = pagegenerators.PreloadingGenerator(talkPages) # do work for page in talkPages: leadSectionFormatter = LeadSectionFormatter(page) leadSectionFormatter.run()
def setUpClass(cls): cls.broswer = webdriver.Chrome() cls.broswer.get("xxxx/login") login(cls) cls.broswer.find_element_by_xpath('/html/body/div/ng-include[2]/aside/nav[2]/ul/li[2]').click() sleep(2)
import sys import urllib import xmlrpclib import common def parse_args(): ap = argparse.ArgumentParser() ap.add_argument("-c", "--channel", default = [], dest = "channels", nargs = "+") ap.add_argument("--createrepo", action = "store_true") return ap.parse_args() if __name__ == "__main__": args = parse_args() (client, sessionKey) = common.login() for channel in args.channels: print >>sys.stderr, "Dumping channel %s..." % channel if not os.path.exists(channel): os.mkdir(channel) pkgs = client.channel.software.listLatestPackages(sessionKey, channel) for i, pkg in enumerate(pkgs): filename = client.packages.getDetails(sessionKey, pkg["id"])["file"] print >>sys.stderr, "[%u/%u] %s" % (i + 1, len(pkgs), filename) urllib.urlretrieve(client.packages.getPackageUrl(sessionKey, pkg["id"]), os.path.join(channel, filename)) client.auth.logout(sessionKey)
__author__ = 'Aditya Thakral' from socket import * import common import time da_ta = common.login() if da_ta[0]: user = da_ta[1] ip = common.validateip() port = common.port() s = socket(AF_INET, SOCK_STREAM) own = socket(AF_INET, SOCK_STREAM) while True: try: own.connect((common.ownip(), port)) break except: print 'Please run receiver first!' time.sleep(5) s.connect((ip, port)) while True: say = raw_input('Input Text: ') if say == '<Exit Code 7-Alpha-Victor>': print 'Good bye!' s.send('Good bye!') print 'Closing in: ' for i in range(5, 0, -1): print i
def setUpClass(cls): cls.broswer = webdriver.Chrome() cls.broswer.get("xxxx/login") login(cls)