@@ -55,11 +55,10 @@ def shutdownServer():
55
55
56
56
class VncServer :
57
57
58
- def __init__ (self , display = "1" , root = "/" , ip = None , name = None ,
58
+ def __init__ (self , root = "/" , ip = None , name = None ,
59
59
password = "" , vncconnecthost = "" ,
60
60
vncconnectport = "" , log_file = "/tmp/vncserver.log" ,
61
61
pw_file = "/tmp/vncpassword" ):
62
- self .display = display
63
62
self .root = root
64
63
self .ip = ip
65
64
self .name = name
@@ -123,9 +122,11 @@ def initialize(self):
123
122
name_ips = [i [4 ][0 ] for i in socket .getaddrinfo (self .name , 0 )]
124
123
if self .name is not None and not self .name .startswith ('localhost' ) \
125
124
and ipstr is not None and self .ip in name_ips :
126
- self .connxinfo = "%s:%s (%s:%s)" % (socket .getfqdn (name = self .name ), self .display , ipstr , self .display )
125
+ self .connxinfo = "%s:%s (%s:%s)" % \
126
+ (socket .getfqdn (name = self .name ), constants .X_DISPLAY_NUMBER ,
127
+ ipstr , constants .X_DISPLAY_NUMBER )
127
128
elif ipstr is not None :
128
- self .connxinfo = "%s:%s" % (ipstr , self . display , )
129
+ self .connxinfo = "%s:%s" % (ipstr , constants . X_DISPLAY_NUMBER )
129
130
else :
130
131
self .connxinfo = None
131
132
@@ -157,7 +158,7 @@ def connectToView(self):
157
158
else :
158
159
hostarg = self .vncconnecthost
159
160
160
- vncconfigcommand = [self .root + "/usr/bin/vncconfig" , "-display" , ":%s" % self . display , "-connect" , hostarg ]
161
+ vncconfigcommand = [self .root + "/usr/bin/vncconfig" , "-display" , ":%s" % constants . X_DISPLAY_NUMBER , "-connect" , hostarg ]
161
162
162
163
for _i in range (maxTries ):
163
164
vncconfp = iutil .startProgram (vncconfigcommand , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) # vncconfig process
@@ -184,7 +185,7 @@ def startVncConfig(self):
184
185
185
186
self .log .info (_ ("Attempting to start vncconfig" ))
186
187
187
- vncconfigcommand = [self .root + "/usr/bin/vncconfig" , "-nowin" , "-display" , ":%s" % self . display ]
188
+ vncconfigcommand = [self .root + "/usr/bin/vncconfig" , "-nowin" , "-display" , ":%s" % constants . X_DISPLAY_NUMBER ]
188
189
189
190
# Use startProgram to run vncconfig in the background
190
191
iutil .startProgram (vncconfigcommand , stdout = self .openlogfile (), stderr = subprocess .STDOUT )
@@ -199,7 +200,7 @@ def VNCListen(self):
199
200
else :
200
201
self .log .info (_ ("Please manually connect your vnc client to <IP ADDRESS>:%s "
201
202
"to begin the install. Switch to the shell (Ctrl-B 2) and "
202
- "run 'ip addr' to find the <IP ADDRESS>." ), self . display )
203
+ "run 'ip addr' to find the <IP ADDRESS>." ), constants . X_DISPLAY_NUMBER )
203
204
204
205
def startServer (self ):
205
206
self .log .info (_ ("Starting VNC..." ))
@@ -226,7 +227,7 @@ def startServer(self):
226
227
self .setVNCPassword ()
227
228
228
229
# Lets start the xvnc.
229
- xvnccommand = [ XVNC_BINARY_NAME , ":%s" % self . display ,
230
+ xvnccommand = [ XVNC_BINARY_NAME , ":%s" % constants . X_DISPLAY_NUMBER ,
230
231
"-depth" , "16" , "-br" ,
231
232
"IdleTimeout=0" , "-auth" , "/dev/null" , "-once" ,
232
233
"DisconnectClients=false" , "desktop=%s" % (self .desktop ,),
@@ -266,8 +267,6 @@ def startServer(self):
266
267
else :
267
268
self .VNCListen ()
268
269
269
- os .environ ["DISPLAY" ]= ":%s" % self .display
270
-
271
270
# Start vncconfig for copy/paste
272
271
self .startVncConfig ()
273
272
0 commit comments