def option(selection): """Selction based on the number you chose. Look at list to modify. Args: selection (int): Runs lines of code based on a conditional Returns: [void]: Doesn't return anything. Just here in case errors. """ if (selection == 1): clear() auth.main() optionUI() elif (selection == 2): print("Run the command 'Ctrl C' to exit the program.") print("Loading Code ...") sleep(2) clear() richpresence.richpresence() elif (selection == 3): if (path.isdir(application_path() + "\\tokens") == True): shutil.rmtree(application_path() + "\\tokens") with open(richpresence.application_path() + "\\rpc.json", 'w') as j: rpc = {"details": "", "state": "", "device": "", "game": ""} json.dump(rpc, j, indent=2) sleep(2) clear() optionUI() elif (selection == 4): sys.exit() else: print("WIP") sleep(2) clear() optionUI()
def test_main(cloud_config, capsys): auth.main(cloud_config.project) output, _ = capsys.readouterr() assert re.search( re.compile( r'Timeseries.list raw response:\s*' r'{\s*"kind": "[^"]+",' r'\s*"oldest": *"[0-9]+', re.S), output)
def test_main(cloud_config, capsys): auth.main(cloud_config.project) output, _ = capsys.readouterr() assert re.search( re.compile( r'Timeseries.list raw response:\s*' r'{\s*"kind": "[^"]+",' r'\s*"oldest": *"[0-9]+', re.S), output)
def main(): auth.main("out.csv", "memes2.0") BigParserAccountEmail = "*****@*****.**" BigParserAccountPassword = "******" FileIDFromGrid = "58d772a8198457064e9113da" url = "https://www.bigparser.com/APIServices/api/common/login" data = { "emailId": BigParserAccountEmail, "password": BigParserAccountPassword, "loggedIn": True } data_json = json.dumps(data) headers = {'Content-type': 'application/json'} authId = requests.post(url, data=data_json, headers=headers).json()['authId'] url = "https://www.bigparser.com/connectors-api/api/apps/file/googleDrive/false" data = {"fileIDs": [FileIDFromGrid]} data_json = json.dumps(data) headers = {'Content-type': 'application/json', 'authId': authId} response = requests.put(url, data=data_json, headers=headers).json() try: url = "https://www.bigparser.com/connectors-api/api/apps/file/googleDrive/" + response[ 'requestId'] + "/status" headers = {'authId': authId} response = requests.get(url, headers=headers).json() # print(response) except KeyError: print( "Your Grid is already synced up to the most recent version of your Google Sheet" )
def get_emails(f): result = [] for line in f.read().split("\n"): # go from all lines in file (in fact we have only 1 line) if line == "": # if empty line continue st = line parsed_json = json.loads(st) # parse by json c = 0 for v in parsed_json['rows']: # go by all records in DB if len(v['cell'][7]) != 8 or True: # go by all records in DB # remove True in order to go only by changed passwords res = dict() # new record res["fio"] = v['cell'][8] # save fio res["pas"] = v['cell'][7] # save password res["login"] = v['cell'][6] # save login res["e-mail"] = auth.main(v['cell'][6], v['cell'][7].encode('utf-8')) # extract e-mail print(res["e-mail"]) # '.encode' because of russian passwords result.append(res) # save result in 'result' c += 1 if c > 3: break return result
class TestTemplate(unittest.TestCase): router = main({'__file__': configurationPath}, **settings) def setUp(self): # Initialize functional test framework self.app = webtest.TestApp(self.router) self.logout() # Reset users word = 'Спасибо'.decode('utf-8') self.userS = ReplaceableDict() # Super self.userA = ReplaceableDict() # Active self.userI = ReplaceableDict() # Inactive for userID, valueByKey in enumerate( [self.userS, self.userA, self.userI], 1): wordNumber = word + str(userID) valueByKey['username'] = wordNumber valueByKey['password'] = wordNumber valueByKey['nickname'] = wordNumber valueByKey['email'] = wordNumber + '@example.com' valueByKey['is_active'] = userID != 3 valueByKey['is_super'] = userID == 1 user = User(id=userID, username=valueByKey['username'], password=valueByKey['password'], nickname=valueByKey['nickname'], email=valueByKey['email'], is_active=valueByKey['is_active'], is_super=valueByKey['is_super']) db.merge(user) transaction.commit() def get_url(self, name, **kwargs): 'Return URL for route' return self.router.routes_mapper.generate(name, kwargs) def get(self, url, params=None): 'Send a GET request' return self.app.get(url, unicode_dictionary(params)) def post(self, url, params=None): 'Send a POST request' return self.app.post(url, unicode_dictionary(params)) def login(self, userD): 'Login using credentials' return self.post(self.get_url('user_login'), userD) def logout(self): 'Logout' return self.post(self.get_url('user_logout')) def assert_json(self, response, isOk): 'Assert response JSON' data = simplejson.loads(response.unicode_body) if data['isOk'] != isOk: print data self.assertEqual(data['isOk'], isOk) return data def assert_forbidden(self, url, isForbidden=True, method='GET'): 'Return True if the page is forbidden' body = getattr(self, method.lower())(url).body return self.assertEqual('value=Login' in body, isForbidden)
def list_accounts(): """List all accounts """ service = auth.main() accounts = service.management().accounts().list().execute() df = pd.read_json(json.dumps(accounts.get('items'))) return df[['id','name']]
import json import pandas as pd import auth service = auth.main() def list_accounts(): """List all accounts """ service = auth.main() accounts = service.management().accounts().list().execute() df = pd.read_json(json.dumps(accounts.get('items'))) return df[['id','name']] def list_properties(account): """List all properties based on id column """ properties = service.management().webproperties().list( accountId=account).execute() df = pd.read_json(json.dumps(properties.get('items'))) return df[['accountId', 'id' , 'name']] def list_profiles(account, property): """List all properties based on id column from list_accounts() & id column form list_properties()""" profiles = service.management().profiles().list( accountId=account, webPropertyId=property).execute() df = pd.read_json(json.dumps(profiles.get('items'))) return df[['accountId', 'id', 'name']] def get_example(profile_id): """Example query based on id column from list_profiles()""" return ga_to_df(service.data().ga().get(
#!/usr/bin/env python3 import auth import json import io from apiclient import http from apiclient import errors from apiclient.http import MediaIoBaseDownload "The first thing to do now is to send and get an http response" drive_service = auth.main() def list_files(): all_files = [] page_token = None while True: files = drive_service.files().list(pageToken=page_token).execute() page_token = files.get('nextPageToken', None) files = files["files"] for individual_files in files: individual_files = individual_files['name'] all_files.append(individual_files) if page_token is None: break return all_files
def upload(file_name, file_path, type='image/jpeg'): # Upload photos in this project photo_metadata = {'name': file_name} media = MediaFileUpload(file_path, mimetype=type) photo = service.files().create(body=photo_metadata, media_body=media, fields='id').execute() print('File ID: %s' % photo.get('id')) if __name__ == '__main__': pass else: # auth will search for token.pickle, or create one auth.main() service = build('drive', 'v3', credentials=auth.creds) # Check if the target folder is already in Google Drive response = service.files().list( q="name='" + target_folder + "' and mimeType='application/vnd.google-apps.folder'", spaces='drive').execute() if not response['files']: # Create the folder file_metadata = { 'name': target_folder, 'mimeType': 'application/vnd.google-apps.folder' } file = service.files().create(body=file_metadata,
#!/usr/bin/env python3 from auth import main from pyannotate_runtime import collect_types if __name__ == '__main__': collect_types.init_types_collection() collect_types.resume() main() collect_types.pause() collect_types.dump_stats('type_info.json')
def richpresence(): """The main code need for the presence app to run """ if (path.exists(application_path() + '\\rpc.json') != True): writejsonfile() client_id = { "main": "700853075023233024", "Halo R": "725163293240590386", "Halo CE": "725898626290942053", "Halo 2": "730097982523047936", "Halo 3": "748408159479005294", "Halo 4": "748413810548801587" } changedRPC = { "Else": "700853075023233024", "Halo R": False, "Halo CE": False, "Halo 2": False, "Halo 3": False, "Halo 4": False } currentRPC = startRPC(client_id['main']) currentRPC.connect() browsingStamp = timestamp() # Creating steam invite link presence = readPresence() if (presence['steamid'] != ""): headers = {'Content-type': 'application/x-www-form-urlencoded'} try: print("Getting steam url code:") r = requests.get( "https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=80EC429274AF252714363656B71562C0&format=json&steamids=" + presence['steamid'], headers=headers) response = json.loads(r.text) lobbysteamid = response['response']['players'][0]['lobbysteamid'] gameid = response['response']['players'][0]['gameid'] steam_invite_url = "steam://joinlobby/" + gameid + "/" + lobbysteamid + "/" + presence[ 'steamid'] pass except Exception as e: print( "Unable to get steam id. Check to make sure Halo is running.") sleep(5) steam_invite_url = None pass else: print("Steam url is None.") steam_invite_url = None pass while True: auth.main() try: request(application_path()) presence = readPresence() if (presence != False and presence['game'] != ""): if (presence['device'] == "Win32" or presence['device'] == "WindowsOneCore"): if (presence['device'] == "Win32"): deviceTitle = "Steam" device = "steam" elif (presence['device'] == "WindowsOneCore"): deviceTitle = "Windows Store/Gamepass" device = "small" else: deviceTitle = "Windows" device = "small" else: device = "xbox" deviceTitle = "Xbox" ## Halo 3 if (presence['state'].find("H3:") != -1): if (changedRPC['Halo 3'] == False): if ((changedRPC['Else'] or changedRPC['Halo CE'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 2'] = False changedRPC['Halo R'] = False changedRPC['Halo 4'] = False currentRPC = startRPC(client_id['Halo 3']) currentRPC.connect() changedRPC['Else'] = False changedRPC['Halo 3'] = client_id['Halo 3'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(3)[ presence['details']], presence['details'], dictionary.jsonDictionary(3)['Halo3'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(3)[ presence['details']], presence['details'], dictionary.jsonDictionary(3)['Halo3'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(3)[ presence['details']], presence['details'], dictionary.jsonDictionary(3)['Halo3'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(3)[ presence['details']], presence['details'], dictionary.jsonDictionary(3)['Halo3'], presence['state'], presence['state'], presence['details'], browsingStamp) elif (presence['state'].find("H4:") != -1): if (changedRPC['Halo 4'] == False): if ((changedRPC['Else'] or changedRPC['Halo CE'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 2'] = False changedRPC['Halo R'] = False changedRPC['Halo 3'] = False currentRPC = startRPC(client_id['Halo 4']) currentRPC.connect() changedRPC['Else'] = False changedRPC['Halo 4'] = client_id['Halo 4'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(4)[ presence['details']], presence['details'], dictionary.jsonDictionary(4)['Halo4'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(4)[ presence['details']], presence['details'], dictionary.jsonDictionary(4)['Halo4'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(4)[ presence['details']], presence['details'], dictionary.jsonDictionary(4)['Halo4'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(4)[ presence['details']], presence['details'], dictionary.jsonDictionary(4)['Halo4'], presence['state'], presence['state'], presence['details'], browsingStamp) elif (presence['state'].find("H: CE:") != -1): if (changedRPC['Halo CE'] == False): if ((changedRPC['Else'] or changedRPC['Halo 4'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo 4'] = False changedRPC['Halo 2'] = False changedRPC['Halo 3'] = False changedRPC['Halo R'] = False changedRPC['Else'] = False currentRPC = startRPC(client_id['Halo CE']) currentRPC.connect() changedRPC['Halo CE'] = client_id['Halo CE'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(1)[ presence['details']], presence['details'], dictionary.jsonDictionary(1)['HaloCE'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(1)[ presence['details']], presence['details'], dictionary.jsonDictionary(1)['HaloCE'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(1)[ presence['details']], presence['details'], dictionary.jsonDictionary(1)['HaloCE'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(1)[ presence['details']], presence['details'], dictionary.jsonDictionary(1)['HaloCE'], presence['state'], presence['state'], presence['details'], browsingStamp) elif (presence['state'].find("H2A: ") != -1): if (changedRPC['Halo 2'] == False): if ((changedRPC['Else'] or changedRPC['Halo 4'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 4'] = False changedRPC['Halo 3'] = False changedRPC['Halo R'] = False changedRPC['Else'] = False currentRPC = startRPC(client_id['Halo 2']) currentRPC.connect() changedRPC['Halo 2'] = client_id['Halo 2'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Aniversary'] [presence['details']], presence['details'], dictionary.jsonDictionary(2)['Halo2Aniversary'] ['Halo2A'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Aniversary'] [presence['details']], presence['details'], dictionary.jsonDictionary( 2)['Halo2Aniversary']['Halo2A'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Aniversary'] [presence['details']], presence['details'], dictionary.jsonDictionary(2)['Halo2Aniversary'] ['Halo2A'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Aniversary'] [presence['details']], presence['details'], dictionary.jsonDictionary( 2)['Halo2Aniversary']['Halo2A'], presence['state'], presence['state'], presence['details'], browsingStamp) elif (presence['state'].find("H2: ") != -1): if (changedRPC['Halo 2'] == False): if ((changedRPC['Else'] or changedRPC['Halo 4'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 4'] = False changedRPC['Halo R'] = False changedRPC['Halo 3'] = False changedRPC['Else'] = False currentRPC = startRPC(client_id['Halo 2']) currentRPC.connect() changedRPC['Halo 2'] = client_id['Halo 2'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Classic'][ presence['details']], presence['details'], dictionary.jsonDictionary(2)['Halo2Classic'] ['Halo2'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Classic'][ presence['details']], presence['details'], dictionary.jsonDictionary( 2)['Halo2Classic']['Halo2'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Classic'][ presence['details']], presence['details'], dictionary.jsonDictionary(2)['Halo2Classic'] ['Halo2'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(2)['Halo2Classic'][ presence['details']], presence['details'], dictionary.jsonDictionary( 2)['Halo2Classic']['Halo2'], presence['state'], presence['state'], presence['details'], browsingStamp) elif (presence['state'].find("H: R:") != -1): if (changedRPC['Halo R'] == False): if ((changedRPC['Else'] or changedRPC['Halo 4'] or changedRPC['Halo 2'] or changedRPC['Halo 4']) != False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 4'] = False changedRPC['Halo 3'] = False changedRPC['Else'] = False currentRPC = startRPC(client_id['Halo R']) currentRPC.connect() changedRPC['Halo R'] = client_id['Halo R'] browsingStamp = timestamp() if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(0)[ presence['details']], presence['details'], dictionary.jsonDictionary(0)['HaloReach'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(0)[ presence['details']], presence['details'], dictionary.jsonDictionary(0)['HaloReach'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc( currentRPC, dictionary.jsonDictionary(0)[ presence['details']], presence['details'], dictionary.jsonDictionary(0)['HaloReach'], presence['state'], presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc( currentRPC, dictionary.jsonDictionary(0)[ presence['details']], presence['details'], dictionary.jsonDictionary(0)['HaloReach'], presence['state'], presence['state'], presence['details'], browsingStamp) else: if (changedRPC['Else'] == False): currentRPC.close() changedRPC['Halo CE'] = False changedRPC['Halo 2'] = False changedRPC['Halo 3'] = False changedRPC['Halo 4'] = False currentRPC = startRPC(client_id['main']) currentRPC.connect() changedRPC['Else'] = client_id['main'] browsingStamp = timestamp() if (steam_invite_url): rpc(currentRPC, "large", presence['game'], device, deviceTitle, presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc(currentRPC, "large", presence['game'], device, deviceTitle, presence['state'], presence['details'], browsingStamp) else: if (steam_invite_url): rpc(currentRPC, "large", presence['game'], device, deviceTitle, presence['state'], presence['details'], browsingStamp, steam_invite_url) else: rpc(currentRPC, "large", presence['game'], device, deviceTitle, presence['state'], presence['details'], browsingStamp) else: print("Waiting for Halo Master Chief Collection to start.") if (steam_invite_url): print(steam_invite_url) sleep(7) clear() except KeyboardInterrupt or ValueError as e: print(e) currentRPC.close() pass