1
2
3
4
5
6
7
8
9
10
11
12
13 import sys
14 import os
15
16 import gettext
17 t = gettext.translation('rhn-client-tools', fallback=True)
18
19 if not hasattr(t, 'ugettext'):
20 t.ugettext = t.gettext
21 _ = t.ugettext
22
23 from up2date_client import up2dateLog
24 up2dateLog.initLog().set_app_name('rhn_register')
25 from up2date_client import up2dateAuth
26 from up2date_client import rhncli
27 from up2date_client import tui
28 from up2date_client import up2dateErrors
29
31 """Runs rhn_register. Can run it in gui or tui mode depending on
32 availablility of gui, DISPLAY environment variable, and --nox switch.
33
34 """
36 super(RhnRegister, self).__init__()
37 self.optparser.add_option("--nox", action="store_true", default=False,
38 help=_("Do not attempt to use X"))
39
41 try:
42 if os.environ["DISPLAY"] != "" and \
43 not self.options.nox:
44 from up2date_client import gui
45 self.hasGui = True
46 return gui
47 except:
48 pass
49
50 return tui
51
53 """RhnCli (the base class) just sets stuff up and then calls this to run
54 the rest of the program.
55
56 """
57 ui = self._get_ui()
58 ui.main()
59
60
61 try:
62 if not up2dateAuth.getLoginInfo():
63 if not self._testRhnLogin():
64 sys.exit(1)
65 except up2dateErrors.RhnServerException:
66 sys.exit(1)
67
68
69
70 self.saveConfig()
71 sys.exit(0)
72
73
74 if __name__ == "__main__":
75 app = RhnRegister()
76 app.run()
77