def main(): from gate import create_default_gate profile = smolt.create_profile(create_default_gate(), smolt.read_uuid()) session = requests.Session() session.headers.update({'USER-AGENT': opts.user_agent}) o = session.post(opts.smoonURL + '', timeout=opts.timeout) exceptions = (requests.exceptions.HTTPError, requests.exceptions.URLRequired, requests.exceptions.Timeout, requests.exceptions.ConnectionError, requests.exceptions.InvalidURL) #first find out the server desired protocol try: #fli is a file like item pub_uuid_fli = opts.smoonURL + 'client/pub_uuid?uuid=%s' % profile.host.UUID pub_uuid_fli = session.get(pub_uuid_fli, timeout=opts.timeout) except exceptions as e: error(_('Error contacting Server: %s') % e) return 1 try: pub_uuid_obj = pub_uuid_fli.json() try: print(_('To view your profile visit: %s') % smolt.get_profile_link(opts.smoonURL, pub_uuid_obj["pub_uuid"])) except ValueError as e: error(_('Something went wrong fetching the public UUID')) finally: session.close()
def main(): ensure_code_reachability() from i18n import _ import smolt from gate import create_default_gate, create_gate_from_file from uuiddb import create_default_uuiddb (opts, args) = command_line() if opts.the_only_config_file is None: gate = create_default_gate() else: gate = create_gate_from_file(opts.the_only_config_file) smolt.DEBUG = opts.DEBUG smolt.hw_uuid_file = opts.uuidFile profile = read_profile(gate, smolt.read_uuid()) if opts.new_pub: uuiddb = create_default_uuiddb() uuid = smolt.read_uuid() main_request_new_public_uuid(uuiddb, uuid, profile, opts) elif not opts.send_profile: main_scan_only(profile, opts) elif opts.printOnly and not opts.autoSend: main_print_only(profile) else: uuiddb = create_default_uuiddb() uuid = smolt.read_uuid() main_send_profile(uuiddb, uuid, profile, opts, gate)
def main(): from gate import create_default_gate profile = smolt.create_profile(create_default_gate(), smolt.read_uuid()) grabber = urlgrabber.grabber.URLGrabber(user_agent=opts.user_agent, timeout=opts.timeout) #first find out the server desired protocol try: #fli is a file like item pub_uuid_fli = grabber.urlopen(urljoin(opts.smoonURL + "/", '/client/pub_uuid?uuid=%s' % profile.host.UUID, False)) except urlgrabber.grabber.URLGrabError, e: error(_('Error contacting Server: %s') % e) return 1