def class_test(): if not os.path.exists('config.yml'): print("config.yml not found") print("please edit config_example.yml and rename it to config.yml") sys.exit(1) import yaml config = yaml.load(file('config.yml')) print "Config loaded" apikey = (config['key'], config['verification']) from evelink.cache.sqlite import SqliteCache evelink_cache = SqliteCache('db/evelink_cache.db') # API with cache and correct api key api = evelink.api.API(api_key=apikey, cache=evelink_cache) print "API connected" # account data a = evelink.account.Account(api) # loop through character id's in api for char_id in a.characters().result: print "Creating character", char_id c = CharacterFactory.create_character(api, char_id) print c.name print c.get_skill_queue_items() print c.get_active_jobs_items()
def main(apikey): from evelink.cache.sqlite import SqliteCache evelink_cache = SqliteCache('db/evelink_cache.db') api = evelink.api.API(api_key=apikey, cache=evelink_cache) a = evelink.account.Account(api) try: for char_id in a.characters().result: print("-" * 30) char = evelink.char.Char(char_id, api) print_charactersheet(char, api) print_industry_jobs(char, api) print_orders(char, api) except evelink.api.APIError, e: print("Api Error:", e)
def onStart(self): if not os.path.exists('config.yml'): print("config.yml not found") print("please edit config_example.yml and rename it to config.yml") sys.exit(1) import yaml config = yaml.load(file('config.yml')) apikey = (config['key'], config['verification']) from evelink.cache.sqlite import SqliteCache evelink_cache = SqliteCache('db/evelink_cache.db') # API with cache and correct api key self.api = evelink.api.API(api_key=apikey, cache=evelink_cache) self.addForm("MAIN", CharacterSummary, name="MAIN") self.addForm("Detailed", CharacterSummary, name="Detailed")
def main(apikey): from evelink.cache.sqlite import SqliteCache evelink_cache = SqliteCache('db/evelink_cache.db') api = evelink.api.API(api_key=apikey, cache=evelink_cache) a = evelink.account.Account(api) # clear the table, makes easier to keep it up to date # updating would work, but removing items that no longer exists is a pain db['assets'].drop() try: for char_id in a.characters().result: print("-" * 30) char = evelink.char.Char(char_id, api) grand_total = print_assets(char, api) print("*" * 30) print(grand_total, "ISK") print("*" * 30) except evelink.api.APIError, e: print("Api Error:", e)
def get_api_key(key): if isinstance(key, API): return key key_id, v_code, entity_id = get_key_config(key) return API(api_key=(key_id, v_code), cache=SqliteCache(_config.get_option('cache_location')))
def setUp(self): self.cache_dir = tempfile.mkdtemp() self.cache_path = os.path.join(self.cache_dir, 'sqlite') self.cache = SqliteCache(self.cache_path)
def keys_from_args(args): return [(int(args[i]), args[i + 1]) for i in range(1, len(args) - 1, 2)] def keys_from_config(config): return [(config.getint(section, 'keyID'), config.get(section, 'vCode')) for section in config.sections() if section.startswith('key:')] if __name__ == "__main__": logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) config = ConfigParser.RawConfigParser() config.read('posmon.ini') print config.get('posmon', 'sde_db_uri') sde_initialize(config.get('posmon', 'sde_db_uri')) if len(sys.argv) > 1: keys = keys_from_args(sys.argv) else: keys = keys_from_config(config) for key_id, vcode in keys: api_key = API(api_key=(key_id, vcode), cache=SqliteCache(config.get('posmon', 'cache'))) if len(sys.argv) > 1: process(api_key, format=sys.argv[1], config=config) else: process(api_key, config=config)
cache_path = config.get('posmon', 'cache') sde_db_uri = config.get('posmon', 'sde_db_uri') try: sentry_uri = config.get('posmon', 'sentry.uri') except ConfigParser.NoOptionError: sentry_uri = None # Set up logging logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) if sentry_uri: from raven.handlers.logging import SentryHandler sentry_handler = SentryHandler(sentry_uri) sentry_handler.setLevel(logging.WARNING) logging.getLogger().addHandler(sentry_handler) sde.initialize(sde_db_uri) # Run! cache=SqliteCache(cache_path) fmt = sys.argv[1] if len(sys.argv) > 1 else 'text' for key_id, vcode in keys: api_key = API(api_key=(key_id, vcode), cache=cache) try: process(api_key, format=fmt, config=config) except Exception as e: if fmt == 'text': print "error processing key: %s" % (str(e),) else: print json.dumps({'error': str(e)}) logging.exception(str(e))