22 from __future__
import print_function
23 from builtins
import str
26 from optparse
import OptionParser
30 sys.path.append(
'/usr/share/smolt/client')
34 from smolt
import error, debug, get_profile_link, PubUUIDError
35 from uuiddb
import create_default_uuiddb
38 for line
in page.split(
"\n"):
39 if 'ServerMessage:' in line:
40 error(
_(
'Server Message: "%s"' % line.split(
'ServerMessage: ')[1]))
41 if 'Critical' in line:
44 parser = OptionParser(version = smolt.smoltProtocol)
46 parser.add_option(
'-d',
'--debug',
49 action =
'store_true',
50 help =
_(
'enable debug information'))
51 parser.add_option(
'-s',
'--server',
53 default = smolt.smoonURL,
55 help =
_(
'specify the URL of the server (default "%default")'))
56 parser.add_option(
'-p',
'--printOnly',
59 action =
'store_true',
60 help =
_(
'print information only, do not send'))
61 parser.add_option(
'-u',
'--useragent',
63 default = smolt.user_agent,
64 metavar =
'USERAGENT',
65 help =
_(
'specify HTTP user agent (default "%default")'))
66 parser.add_option(
'-t',
'--timeout',
69 default = smolt.timeout,
70 help =
_(
'specify HTTP timeout in seconds (default %default seconds)'))
71 parser.add_option(
'--uuidFile',
73 default = smolt.hw_uuid_file,
74 help =
_(
'specify which uuid to use, useful for debugging and testing mostly.'))
77 (opts, args) = parser.parse_args()
79 smolt.DEBUG = opts.DEBUG
80 smolt.hw_uuid_file = opts.uuidFile
82 uuid = smolt.read_uuid()
83 delHostString =
'uuid=%s' % uuid
85 session = requests.Session()
86 session.headers.update({
'USER-AGENT': opts.user_agent})
87 session.headers.update({
'Content-type':
'application/x-www-form-urlencoded'})
88 session.headers.update({
'Content-length':
'%i' % len(delHostString)})
97 exceptions = (requests.exceptions.HTTPError,
98 requests.exceptions.URLRequired,
99 requests.exceptions.Timeout,
100 requests.exceptions.ConnectionError,
101 requests.exceptions.InvalidURL)
104 o = session.post(opts.smoonURL +
'client/delete', data=delHostString,
105 timeout=opts.timeout)
106 except exceptions
as e:
107 sys.stderr.write(
_(
'Error contacting Server:'))
108 sys.stderr.write(str(e))
109 sys.stderr.write(
'\n')
116 profile_url = opts.smoonURL +
'client/show?%s' % delHostString
119 print((
_(
'Profile removed, please verify at'), profile_url))
122 if __name__ ==
'__main__':