def search( query_terms, verbose, count, showAll ): # Make a new instance of API api = API(query_terms) # Load API api.load() # Print results api.display( verbose, count, showAll ) # Print meta data duration = int(round(time.time() * 1000)) - start print "\t%dms total:%d" % ( duration, api.total ) # Return the json results to be saved return api.raw_json
def rpc(): payload = bottle.request.json method = None result = {} try: action = payload['method'] result['id'] = payload['id'] if action == 'walletpassphrase': result['result'] = set_passphrase(*payload['params']) elif action == 'getinfo': result['result'] = get_infos() else: api = API(config.PASSPHRASE, config.DATABASE) result['result'] = api.do(action, payload['params']) result['error'] = None except Exception as e: result['result'] = None result['error'] = {'message':str(e), 'code':-1} #TODO: return same code as bitcoind return json.dumps(result, cls=JsonDecimalEncoder)
def get_app(conf): app = Controller() app.api = API() cherrypy.tree.mount(app, "/", config=conf) global_config = { "engine.autoreload.on": True, "server.socket_host": Configuration.SOCKET_HOST, "server.socket_port": Configuration.SOCKET_PORT, "server.thread_pool": Configuration.THREAD_POOL, "log.error_file": Configuration.ERROR_LOG_PATH, "log.access_file": Configuration.ACCESS_LOG_PATH, "error_page.404": error_404, "error_page.500": error_500 } cherrypy.config.update(global_config) return cherrypy.tree
class App(): def __init__(self, api_key): self.api_key = api_key self.api = API(api_key) def run(self): while True: try: print("Enter the name of a city.") location = input(">>> ") weather = Weather(self.api.get_current_weather(location=location)) weather.display_weather() except ValueError as e: print("Error getting the weather: {}".format(e)) except KeyError as e: print("There was an error reading the weather data at the location you entered.")
def __init__(self, args): super().__init__() self._candy_core = Core() if args.interface: if args.bitrate: bitrate = args.bitrate else: bitrate = 500000 self.candy_core.can_monitor(args.interface, bitrate) self.interface = True if args.log: self.candy_core.can_offline(args.log) # Load and run plugin self.candy_core.find_plugin() print("Loaded modules:", " ".join(self.candy_core.modules)) self._candy_API = API(self._candy_core) self._interface = False
def main(): global api global SAVE_LOG, SAVE_IMAGE, DUMP_API parser = argparse.ArgumentParser(description='Arguments') parser.add_argument('--site_url', help='run with site_url', required=True) parser.add_argument('--save_log', help='save failure validation') parser.add_argument('--save_image', help='save failure validation image') parser.add_argument('--dump_api', help='dump data') parser.add_argument('--restart', help='restart state from the beginning', action='store_true') args = parser.parse_args() SAVE_LOG = args.save_log or SAVE_LOG SAVE_IMAGE = args.save_image or SAVE_IMAGE DUMP_API = args.dump_api or DUMP_API api = API(args.site_url, DUMP_API) logging.basicConfig( format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s', # filename='log/'+datetime.now().strftime('output_%Y%m%d%H%M.log'), # filemode='a', level=logging.CRITICAL) # logging.getLogger().addHandler(logging.StreamHandler()) logging.captureWarnings(True) if args.restart: clear_state() get_metadata() validate_pools() # check_one('6728', '11916', '11965', '11966', '900052080', '6728', '11916', '11965', '11966', '900052080') show_result() show_summary()
import sys import argparse import logging import configparser from lib.search.request import Request from lib.downloader import Downloader from lib.api import API from lib.clipboard import Clipboard from lib.bulkconverter import BulkConverter # MAIN VERSION OF THIS PROGRAM __version_info__ = (0, 1, 2) __version__ = '.'.join(map(str, __version_info__)) api = API() def main(argv): config = configparser.ConfigParser() config_path = os.path.expanduser(os.path.join("~", ".doimgrrc")) if os.path.isfile(config_path): config.read(config_path) parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Command line based tool to request DOI data and convert \ it to BibTex entries.') subparsers = parser.add_subparsers() parser_search = subparsers.add_parser(
fs.seek(0x3b) VERSION = fs.read(4) VERSION = { b"NGEE": "NTSC-U", b"NGEJ": "NTSC-J", b"NGEP": "PAL", }.get(VERSION, VERSION) assert VERSION in acceptable_versions, "Unsupported version {}".format(VERSION) print("Version recognised as {}".format(VERSION)) # ================================================= api = API(VERSION, currentProgram) # Lazily extend api with our splits buffer & name buffer # Our buffers are in the compressed LgunE and LtitleE files splitsBuffer = { "NTSC-U": 0x802AC1C0, "NTSC-J": 0x802AC140, "PAL": 0x8029C1C0 # [-U] -0x10000 + 0x0 }[VERSION] + 0x10 # Note the + 0x10 namesBuffer = { "NTSC-U": 0x802AD160, "NTSC-J": 0x802AD170, "PAL": 0x8029D180 # [-U] -0x10000 + 0x20 (more items of text) }[VERSION] api.splitsBuffer = MemoryAddress(splitsBuffer)
from lib.api import API from lib.client import Client if __name__ == '__main__': try: token = os.environ['VSCALE_API_TOKEN'] except KeyError: print( 'Please set "VSCALE_API_TOKEN" variable to be able to call API. Exiting.' ) sys.exit(1) cache = Cache('~/.vscalectl.yml', remove_cache=True) cache.load() api = API(token, cache) cli = Client(api, no_header=True) res = True res = res & bool( cli.do('images', None, None, { 'image': None, 'plan': None, 'location': None })) print('Images: {}'.format(res)) res = res & bool( cli.do('locations', None, None, {
def __init__(self, api_key): self.api_key = api_key self.api = API(api_key)
#!/usr/bin/env python3 import sys import os.path from lib.config import Config from lib.api import API if __name__ == '__main__': try: config_path = sys.argv[1] if os.path.isfile( sys.argv[1]) else './config/example.yml' except (IndexError, OSError): config_path = './config/example.yml' config = Config(config_path) api = API(config) api.run()