22from builtins
import str
25from optparse
import OptionParser
29 sys.path.append(
'/usr/share/smolt/client')
33 from smolt
import error, debug, get_profile_link, PubUUIDError
34 from uuiddb
import create_default_uuiddb
37 for line
in page.split(
"\n"):
38 if 'ServerMessage:' in line:
39 error(
_(
'Server Message: "%s"' % line.split(
'ServerMessage: ')[1]))
40 if 'Critical' in line:
43 parser = OptionParser(version = smolt.smoltProtocol)
45 parser.add_option(
'-d',
'--debug',
48 action =
'store_true',
49 help =
_(
'enable debug information'))
50 parser.add_option(
'-s',
'--server',
52 default = smolt.smoonURL,
54 help =
_(
'specify the URL of the server (default "%default")'))
55 parser.add_option(
'-p',
'--printOnly',
58 action =
'store_true',
59 help =
_(
'print information only, do not send'))
60 parser.add_option(
'-u',
'--useragent',
62 default = smolt.user_agent,
63 metavar =
'USERAGENT',
64 help =
_(
'specify HTTP user agent (default "%default")'))
65 parser.add_option(
'-t',
'--timeout',
68 default = smolt.timeout,
69 help =
_(
'specify HTTP timeout in seconds (default %default seconds)'))
70 parser.add_option(
'--uuidFile',
72 default = smolt.hw_uuid_file,
73 help =
_(
'specify which uuid to use, useful for debugging and testing mostly.'))
76 (opts, args) = parser.parse_args()
78 smolt.DEBUG = opts.DEBUG
79 smolt.hw_uuid_file = opts.uuidFile
81 uuid = smolt.read_uuid()
82 delHostString =
'uuid=%s' % uuid
84 session = requests.Session()
85 session.headers.update({
'USER-AGENT': opts.user_agent})
86 session.headers.update({
'Content-type':
'application/x-www-form-urlencoded'})
87 session.headers.update({
'Content-length':
'%i' % len(delHostString)})
96 exceptions = (requests.exceptions.HTTPError,
97 requests.exceptions.URLRequired,
98 requests.exceptions.Timeout,
99 requests.exceptions.ConnectionError,
100 requests.exceptions.InvalidURL)
103 o = session.post(opts.smoonURL +
'client/delete', data=delHostString,
104 timeout=opts.timeout)
105 except exceptions
as e:
106 sys.stderr.write(
_(
'Error contacting Server:'))
107 sys.stderr.write(str(e))
108 sys.stderr.write(
'\n')
115 profile_url = opts.smoonURL +
'client/show?%s' % delHostString
118 print((
_(
'Profile removed, please verify at'), profile_url))
121if __name__ ==
'__main__':
def get_profile_link(smoonURL, pub_uuid)
This is another.
def create_default_uuiddb()