def handle(parser): args = parser.parse_args() banner() check_update(args) config_parser() domains_dic = {} # asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) if args.debug: debug = True logger.set_level(CUSTOM_LOGGING.DEBUG) nomal = args.nomal if args.help: parser.print_help() elif args.domain: domain = check_domain(args.domain) if not domain: sys.exit(logger.error("Error domain: %s" % domain)) logger.sysinfo("Loading and checking domain %s." % args.domain) domains_dic[domain]=[domain] run(domains_dic,nomal) elif args.domain_file: if os.path.isdir(args.domain_file): domain_file_list = glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), "domain",'*.*')) for domain_file in domain_file_list: domains_dic[os.path.basename(domain_file)] = [] logger.sysinfo("Loading and checking domains of file %s." % args.domain_file) with open(domain_file, 'r') as f: for domain in f.readlines(): domain = check_domain(domain) if not domain: logger.error("Error domain: %s" % domain) continue domains_dic[os.path.basename(domain_file)].append(domain) run(domains_dic,nomal) elif os.path.isfile(args.domain_file): domains_dic[os.path.basename(args.domain_file)] = [] logger.sysinfo("Loading and checking domains of file %s." % args.domain_file) with open(args.domain_file, 'r') as f: for domain in f.readlines(): domain = check_domain(domain) if not domain: logger.error("Error domain: %s" % domain) continue domains_dic[os.path.basename(args.domain_file)].append(domain) run(domains_dic,nomal) else: logger.sysinfo("Error for domain file, please check the file %s." % args.domain_file) else: parser.print_help()
validation = None api_key = None data = data_structure.Data(cookie, company_id, email_format, domain, filename, keyword, validation, api_key) logger.debug(str(vars(data))) for k, v in vars(data).items(): if v != None: logger.yellow('%s set to %s' % (k, logger.YELLOW(v))) else: logger.debug('%s set to None' % k) print() try: logger.debug('Running core.run()') users = core.run(data) except KeyboardInterrupt: logger.yellow('Keyboard interrupt detected!') quit() logger.green('Done!') finish_time = datetime.datetime.now().replace(microsecond=0) duration = finish_time - start_time logger.blue('Runtime: %s' % logger.BLUE(duration))
def browse(): try: type = request.POST['browse'] results = tdb.search(type) # sort by key list1 = [] results.sort(key=itemgetter(type)) for key, items in groupby(results, itemgetter(type)): list1.append({key: list(items)}) response.charset = 'UTF-8' return dumps(list1, indent=2) except: return "500" @route('/search', method='POST') def search(): try: query = request.POST['query'] results = tdb.search(query) return dumps(results, indent=2) except KeyboardInterrupt: return "500" @route('/buy', method='POST') def buy(): pass if __name__ == "__main__": run(server=TornadoServer, port=8888)
#! /usr/bin/python #! coding: utf-8 # pylint: disable-msg=W0311 from lib.core import run, route, TornadoServer @route('/') def index(): return 'Hello World!' run(server=TornadoServer, port=8080)
def mutate(self, info, **agrs): response = core.run(**agrs) return OptimalTime(response=response)
def optimal_time(): result = core.run(**request.json) return Response(json.dumps({"result": result}), status=200, mimetype='application/json')
#! /usr/bin/python #! coding: utf-8 # pylint: disable-msg=W0311 from lib.core import run, route, TornadoServer @route('/error_400') def bad_request(): return str({"error_code": "400"}) @route('/error_500') def internal_server_error(): return str({"error_code": "500"}) @route('/error_404') def not_found(): return str({"error_code": "404"}) @route('/error_405') def method_not_allowed(): return str({"error_code": "405"}) if __name__ == '__main__': run(server=TornadoServer, port=9999)