def parseArguments(): parser = argparse.ArgumentParser() parser.add_argument("-e", "--email-address", dest="email", action="store", help="e-mail used to log into ingress") parser.add_argument("-p", "--password", dest="password", action="store", help="password for your e-mail") parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False, help="Debug output") parser.add_argument("-f", "--from-file", dest="fromFile", action="store", help="Config postfix for the user you want to do (e.g. WillWheaton is ~/.b07_WillWheaton)") parser.add_argument("-m", "--mail", dest="mail", action="store_true", default=False, help="Use -m if you want the system to email you a kml file of your keys") parser.add_argument("-g", "--no-gear", dest="gear", action="store_false", default=True, help="Use -g if you don't want the system to output your gear to the screen") parser.add_argument("-k", "--no-keys", dest="keys", action="store_false", default=True, help="Use -m if you don't want the system to output your keys to the system") parser.add_argument("-l", "--log-stats", dest="log", action="store_true", default=False, help="Store AP Statistics into a database") args = parser.parse_args() global fromFile, file, email, password file = "~/.b07" if args.email is None or args.password is None: fromFile = True if fromFile: if not args.fromFile is None: file = "~/.b07_"+args.fromFile # it's very important to set up logging very early in the life of an # application... if args.debug: setup(reactor, TRACE) else: setup(reactor, INFO) settings["mail"] = args.mail settings["keys"] = args.keys settings["gear"] = args.gear settings["log"] = args.log info("{}".format(settings)) email = args.email password = args.password
def logportals(inventory, reactor): now = datetime.datetime.now() inv_count = 0 # Print out keys and counts filename = file if writeConfig: filename = "~/.b07_"+api.player_nickname createConfigFile(filename) b07.portals.writeKMLFile(api.player_nickname) b07.gear.writeGear(api.player_nickname) if settings["keys"]: b07.portals.logportals() # write KML file # print out gear if settings["gear"]: b07.gear.loggear() # Email KML file if settings["mail"]: emailKMLFile(api.player_nickname,api.email,filename) if settings["log"]: logStatistics(api,filename) if api.new_version: emailVersionUpdate(api.player_nickname,api.email,filename) shutil.copy2(os.path.expanduser("~/{}_config.cfg".format(api.player_nickname)),os.path.expanduser("~/{}_config_old.cfg".format(api.player_nickname))) while api.inventory_done == False or api.profile_done == False: info("waiting for stuff to finish") time.sleep(5) info("everything is complete") reactor.stop()
def logportals(inventory, reactor): now = datetime.datetime.now() inv_count = 0 # Print out keys and counts filename = file if writeConfig: filename = "~/.b07_" + api.player_nickname createConfigFile(filename) b07.portals.writeKMLFile(api.player_nickname) b07.gear.writeGear(api.player_nickname) if settings["keys"]: b07.portals.logportals() # write KML file # print out gear if settings["gear"]: b07.gear.loggear() # Email KML file if settings["mail"]: emailKMLFile(api.player_nickname, api.email, filename) if settings["log"]: logStatistics(api, filename) if api.new_version: emailVersionUpdate(api.player_nickname, api.email, filename) shutil.copy2( os.path.expanduser("~/{}_config.cfg".format(api.player_nickname)), os.path.expanduser("~/{}_config_old.cfg".format(api.player_nickname))) while api.inventory_done == False or api.profile_done == False: info("waiting for stuff to finish") time.sleep(5) info("everything is complete") reactor.stop()
def _authenticate5(self, result): trace('_authenticate5 {}'.format(result)) result = result['result'] if 'xsrfToken' not in result: critical('Authentication with Ingress severs failed for unknown reason') self.xsrf_token = str(result['xsrfToken']) self.player_nickname = result['nickname'] self.player_guid = result['playerEntity'][0] self.team = result['playerEntity'][2]['controllingTeam']['team'] self.ap = result['playerEntity'][2]['playerPersonal']['ap'] self.level = result['playerEntity'][2]['playerPersonal']['clientLevel'] start_date = result['storage']['mission_complete_0'] self.start_date = datetime.datetime.fromtimestamp(int(start_date.split(':delim:')[1])/1000) debug('XSRF Token: {}'.format(self.xsrf_token)) debug('Player GUID: {}'.format(self.player_guid)) info('Player nickname: {}'.format(self.player_nickname)) info('Faction: {}'.format(self.team)) info('AP: {}'.format(self.ap)) info('Level: {}'.format(self.level)) info('Start Date: {}'.format(self.start_date)) debug('Player info: {}'.format(result)) with open(os.path.expanduser("~/{}_config.cfg".format(self.player_nickname)),"w") as file: json.dump(result, file, indent=1) self.new_version = versionCheck(result['serverVersion'], self.player_nickname) self._process_deferred_api_requests()
def parseArguments(): parser = argparse.ArgumentParser() parser.add_argument("-e", "--email-address", dest="email", action="store", help="e-mail used to log into ingress") parser.add_argument("-p", "--password", dest="password", action="store", help="password for your e-mail") parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False, help="Debug output") parser.add_argument("-f", "--from-file", dest="config", action="store_true", default=False, help="Use -f if you want to use the configuration at ~/.b07") parser.add_argument("-m", "--mail", dest="mail", action="store_true", default=False, help="Use -m if you want the system to email you a kml file of your keys") parser.add_argument("-g", "--no-gear", dest="gear", action="store_false", default=True, help="Use -g if you don't want the system to output your gear to the screen") parser.add_argument("-k", "--no-keys", dest="keys", action="store_false", default=True, help="Use -m if you don't want the system to output your keys to the system") args = parser.parse_args() global fromFile if args.email is None or args.password is None: args.config = True fromFile = args.config # it's very important to set up logging very early in the life of an # application... if args.debug: setup(reactor, TRACE) else: setup(reactor, INFO) settings["mail"] = args.mail settings["keys"] = args.keys settings["gear"] = args.gear info("{}".format(settings)) return(args.email, args.password)
def _authenticate5(self, result): result = result['result'] if result['versionMatch'] != 'CURRENT': critical('Software version not up-to-date') if 'xsrfToken' not in result: critical('Authentication with Ingress severs failed for unknown reason') self.xsrf_token = str(result['xsrfToken']) self.player_nickname = result['nickname'] self.player_guid = result['playerEntity'][0] self.team = result['playerEntity'][2]['controllingTeam']['team'] self.ap = result['playerEntity'][2]['playerPersonal']['ap'] self.level = result['playerEntity'][2]['playerPersonal']['clientLevel'] debug('XSRF Token: {}'.format(self.xsrf_token)) debug('Player GUID: {}'.format(self.player_guid)) info('Player nickname: {}'.format(self.player_nickname)) info('Faction: {}'.format(self.team)) info('AP: {}'.format(self.ap)) info('Level: {}'.format(self.level)) debug('Player info: {}'.format(result)) self._process_deferred_api_requests()
def main(): (email, password) = parseArguments() if fromFile: config = ConfigParser.ConfigParser() config.read(os.path.expanduser('~/.b07')) email = config.get('ingress','email') password = config.get('ingress','password') now = datetime.datetime.now() # This is a check for checking which email is being used info('email: '+ email.format(now)) # Password is a debug message in the end, just to ensure proper authentication #info('password: '+password.format(now)) global api api = b07.api.API(reactor, email, password) api.onInventoryRefreshed(logportals, reactor) reactor.run()
def _authenticate5(self, result): trace('_authenticate5 {}'.format(result)) result = result['result'] if 'xsrfToken' not in result: critical( 'Authentication with Ingress severs failed for unknown reason') self.xsrf_token = str(result['xsrfToken']) self.player_nickname = result['nickname'] self.player_guid = result['playerEntity'][0] self.team = result['playerEntity'][2]['controllingTeam']['team'] self.ap = result['playerEntity'][2]['playerPersonal']['ap'] self.level = result['playerEntity'][2]['playerPersonal']['clientLevel'] start_date = result['storage']['mission_complete_0'] self.start_date = datetime.datetime.fromtimestamp( int(start_date.split(':delim:')[1]) / 1000) debug('XSRF Token: {}'.format(self.xsrf_token)) debug('Player GUID: {}'.format(self.player_guid)) info('Player nickname: {}'.format(self.player_nickname)) info('Faction: {}'.format(self.team)) info('AP: {}'.format(self.ap)) info('Level: {}'.format(self.level)) info('Start Date: {}'.format(self.start_date)) debug('Player info: {}'.format(result)) with open( os.path.expanduser("~/{}_config.cfg".format( self.player_nickname)), "w") as file: json.dump(result, file, indent=1) self.new_version = versionCheck(result['serverVersion'], self.player_nickname) self._process_deferred_api_requests()
def logportals(): key_titles = {} keys = Portal.portals.keys() keys.sort(lambda a, b: cmp(Portal.portals[a].title, Portal.portals[b].title)) now = datetime.datetime.now() info('---vvvv Portals known as of {} vvvv---'.format(now)) for key in keys: portal = Portal.portals[key] try: key_titles[portal.title] += 1 except KeyError: key_titles[portal.title] = 1 for key in keys: portal = Portal.portals[key] if key_titles[portal.title] > 1: info('{} ({}): {}'.format(portal.title.encode('ascii','ignore'), portal.address, len(portal.keys))) else: info('{}: {}'.format(portal.title.encode('ascii','ignore'), len(portal.keys))) info('---^^^^ Portals known as of {} ^^^^---'.format(now))
def logportals(): key_titles = {} keys = Portal.portals.keys() keys.sort( lambda a, b: cmp(Portal.portals[a].title, Portal.portals[b].title)) now = datetime.datetime.now() info('---vvvv Portals known as of {} vvvv---'.format(now)) for key in keys: portal = Portal.portals[key] try: key_titles[portal.title] += 1 except KeyError: key_titles[portal.title] = 1 for key in keys: portal = Portal.portals[key] if key_titles[portal.title] > 1: info('{} ({}): {}'.format(portal.title.encode('ascii', 'ignore'), portal.address, len(portal.keys))) else: info('{}: {}'.format(portal.title.encode('ascii', 'ignore'), len(portal.keys))) info('---^^^^ Portals known as of {} ^^^^---'.format(now))
def loggear(): items = Gear.gear info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Item | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Total |" ) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Bursters | %(b1)3d | %(b2)3d | %(b3)3d | %(b4)3d | %(b5)3d | %(b6)3d | %(b7)3d | %(b8)3d | %(bt)4d |" % items) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Ultra Strikes | %(u1)3d | %(u2)3d | %(u3)3d | %(u4)3d | %(u5)3d | %(u6)3d | %(u7)3d | %(u8)3d | %(ut)4d |" % items) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Resonators | %(r1)3d | %(r2)3d | %(r3)3d | %(r4)3d | %(r5)3d | %(r6)3d | %(r7)3d | %(r8)3d | %(rt)4d |" % items) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Power Cubes | %(p1)3d | %(p2)3d | %(p3)3d | %(p4)3d | %(p5)3d | %(p6)3d | %(p7)3d | %(p8)3d | %(pt)4d |" % items) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Media | %(e1)3d | %(e2)3d | %(e3)3d | %(e4)3d | %(e5)3d | %(e6)3d | %(e7)3d | %(e8)3d | %(et)4d |" % items) info( "|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|" ) info( "| Mod | Common | Rare | Very Rare | Total |" ) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Shields | %(sCOMMON)3d | %(sRARE)3d | %(sVERY_RARE)3d | %(st)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Force Amplifiers | %(fCOMMON)3d | %(fRARE)3d | %(fVERY_RARE)3d | %(ft)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Heatsinks | %(hCOMMON)3d | %(hRARE)3d | %(hVERY_RARE)3d | %(ht)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Link Amplifiers | %(lCOMMON)3d | %(lRARE)3d | %(lVERY_RARE)3d | %(lt)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Multihacks | %(mCOMMON)3d | %(mRARE)3d | %(mVERY_RARE)3d | %(mt)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Turrets | %(tCOMMON)3d | %(tRARE)3d | %(tVERY_RARE)3d | %(tt)4d |" % items) info( "|---------------------+-----------+-----------+-----------------+---------|" ) info( "| Viruses | ADA - %(cADA)3d, JARVIS - %(cJARVIS)3d | %(ct)4d |" % items) info( "|---------------------+-----------------------------------------+---------|" ) info( "| TOTAL NUMBER OF ITEMS (Inventory cap is 2000 items) Keys: %(keyt)3d | %(t)4d |" % items) info( "|---------------------------------------------------------------+---------|" )
def main(): parseArguments() global email, password, server, writeConfig config = ConfigParser.ConfigParser() if fromFile: try: config.read(os.path.expanduser(file)) email = config.get('ingress','email') password = config.get('ingress','password') except ConfigParser.NoSectionError: #if ~/.b07 doesn't exist writeConfig = True server = {} info("Please enter your ingress e-mail address: ") email = raw_input() info("Please enter your ingress e-mail password: "******"Do you have an email server you want to use? y/n") response = raw_input() if response.lower() == "y" or response.lower() == "yes": info("email server hostname: ") server["hostname"] = raw_input() info("email server port: ") server["port"] = str(raw_input()) info("email server email account: ") server["email"] = raw_input() info("email server email account password: "******"password"] = raw_input() else: server["hostname"] = "smtp.gmail.com" server["port"] = "587" server["email"] = email server["password"] = password info("You will not enter the database information (if you do not use -l, then this is not needed)") info("As of right now, the database needs to be a mysql database") info("Please enter the database hostname (used for -l): ") database["hostname"] = raw_input() info("Please enter the database username (used for -l): ") database["username"] = raw_input() info("Please enter the database name (used for -l): ") database["database"] = raw_input() info("Please enter the database password (used for -l): ") database["password"] = raw_input() createConfigFile(file) now = datetime.datetime.now() # This is a check for checking which email is being used info('email: '+ email.format(now)) # Password is a debug message in the end, just to ensure proper authentication #info('password: '+password.format(now)) global api api = b07.api.API(reactor, email, password) api.onInventoryRefreshed(logportals, reactor) reactor.run()
def loggear(): items = Gear.gear info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Item | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Total |") info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Bursters | %(b1)3d | %(b2)3d | %(b3)3d | %(b4)3d | %(b5)3d | %(b6)3d | %(b7)3d | %(b8)3d | %(bt)4d |" % items) info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Ultra Strikes | %(u1)3d | %(u2)3d | %(u3)3d | %(u4)3d | %(u5)3d | %(u6)3d | %(u7)3d | %(u8)3d | %(ut)4d |" % items) info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Resonators | %(r1)3d | %(r2)3d | %(r3)3d | %(r4)3d | %(r5)3d | %(r6)3d | %(r7)3d | %(r8)3d | %(rt)4d |" % items) info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Power Cubes | %(p1)3d | %(p2)3d | %(p3)3d | %(p4)3d | %(p5)3d | %(p6)3d | %(p7)3d | %(p8)3d | %(pt)4d |" % items) info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Media | %(e1)3d | %(e2)3d | %(e3)3d | %(e4)3d | %(e5)3d | %(e6)3d | %(e7)3d | %(e8)3d | %(et)4d |" % items) info("|---------------+-----+-----+-----+-----+-----+-----+-----+-----+---------|") info("| Mod | Common | Rare | Very Rare | Total |") info("|---------------------+-----------+-----------+-----------------+---------|") info("| Shields | %(sCOMMON)3d | %(sRARE)3d | %(sVERY_RARE)3d | %(st)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Force Amplifiers | %(fCOMMON)3d | %(fRARE)3d | %(fVERY_RARE)3d | %(ft)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Heatsinks | %(hCOMMON)3d | %(hRARE)3d | %(hVERY_RARE)3d | %(ht)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Link Amplifiers | %(lCOMMON)3d | %(lRARE)3d | %(lVERY_RARE)3d | %(lt)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Multihacks | %(mCOMMON)3d | %(mRARE)3d | %(mVERY_RARE)3d | %(mt)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Turrets | %(tCOMMON)3d | %(tRARE)3d | %(tVERY_RARE)3d | %(tt)4d |" % items) info("|---------------------+-----------+-----------+-----------------+---------|") info("| Viruses | ADA - %(cADA)3d, JARVIS - %(cJARVIS)3d | %(ct)4d |" % items) info("|---------------------+-----------------------------------------+---------|") info("| TOTAL NUMBER OF ITEMS (Inventory cap is 2000 items) Keys: %(keyt)3d | %(t)4d |" % items) info("|---------------------------------------------------------------+---------|")
def main(): parseArguments() global email, password, server, writeConfig config = ConfigParser.ConfigParser() if fromFile: try: config.read(os.path.expanduser(file)) email = config.get('ingress', 'email') password = config.get('ingress', 'password') except ConfigParser.NoSectionError: #if ~/.b07 doesn't exist writeConfig = True server = {} info("Please enter your ingress e-mail address: ") email = raw_input() info("Please enter your ingress e-mail password: "******"Do you have an email server you want to use? y/n") response = raw_input() if response.lower() == "y" or response.lower() == "yes": info("email server hostname: ") server["hostname"] = raw_input() info("email server port: ") server["port"] = str(raw_input()) info("email server email account: ") server["email"] = raw_input() info("email server email account password: "******"password"] = raw_input() else: server["hostname"] = "smtp.gmail.com" server["port"] = "587" server["email"] = email server["password"] = password info( "You will not enter the database information (if you do not use -l, then this is not needed)" ) info("As of right now, the database needs to be a mysql database") info("Please enter the database hostname (used for -l): ") database["hostname"] = raw_input() info("Please enter the database username (used for -l): ") database["username"] = raw_input() info("Please enter the database name (used for -l): ") database["database"] = raw_input() info("Please enter the database password (used for -l): ") database["password"] = raw_input() createConfigFile(file) now = datetime.datetime.now() # This is a check for checking which email is being used info('email: ' + email.format(now)) # Password is a debug message in the end, just to ensure proper authentication #info('password: '+password.format(now)) global api api = b07.api.API(reactor, email, password) api.onInventoryRefreshed(logportals, reactor) reactor.run()
def parseArguments(): parser = argparse.ArgumentParser() parser.add_argument("-e", "--email-address", dest="email", action="store", help="e-mail used to log into ingress") parser.add_argument("-p", "--password", dest="password", action="store", help="password for your e-mail") parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False, help="Debug output") parser.add_argument( "-f", "--from-file", dest="fromFile", action="store", help= "Config postfix for the user you want to do (e.g. WillWheaton is ~/.b07_WillWheaton)" ) parser.add_argument( "-m", "--mail", dest="mail", action="store_true", default=False, help= "Use -m if you want the system to email you a kml file of your keys") parser.add_argument( "-g", "--no-gear", dest="gear", action="store_false", default=True, help= "Use -g if you don't want the system to output your gear to the screen" ) parser.add_argument( "-k", "--no-keys", dest="keys", action="store_false", default=True, help= "Use -m if you don't want the system to output your keys to the system" ) parser.add_argument("-l", "--log-stats", dest="log", action="store_true", default=False, help="Store AP Statistics into a database") args = parser.parse_args() global fromFile, file, email, password file = "~/.b07" if args.email is None or args.password is None: fromFile = True if fromFile: if not args.fromFile is None: file = "~/.b07_" + args.fromFile # it's very important to set up logging very early in the life of an # application... if args.debug: setup(reactor, TRACE) else: setup(reactor, INFO) settings["mail"] = args.mail settings["keys"] = args.keys settings["gear"] = args.gear settings["log"] = args.log info("{}".format(settings)) email = args.email password = args.password