Package x2go :: Module defaults
[frames] | no frames]

Source Code for Module x2go.defaults

  1  # -*- coding: utf-8 -*- 
  2   
  3  # Copyright (C) 2010-2016 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> 
  4  # 
  5  # Python X2Go is free software; you can redistribute it and/or modify 
  6  # it under the terms of the GNU Affero General Public License as published by 
  7  # the Free Software Foundation; either version 3 of the License, or 
  8  # (at your option) any later version. 
  9  # 
 10  # Python X2Go is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  # GNU Affero General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU Affero General Public License 
 16  # along with this program; if not, write to the 
 17  # Free Software Foundation, Inc., 
 18  # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 
 19   
 20  """\ 
 21  Default variables and values for Python X2Go. 
 22   
 23  """ 
 24  __NAME__ = 'x2godefaults-pylib' 
 25   
 26  import os 
 27  import paramiko 
 28  import platform 
 29   
 30  ## 
 31  ## Common X2Go defaults 
 32  ## 
 33   
 34  X2GOCLIENT_OS = platform.system() 
 35   
 36  if X2GOCLIENT_OS != 'Windows': 
 37      import Xlib.display 
 38      import Xlib.error 
 39   
 40      # handle missing X displays on package build 
 41      try: 
 42          X_DISPLAY = Xlib.display.Display() 
 43      except Xlib.error.DisplayNameError: 
 44          X_DISPLAY = None 
 45      except Xlib.error.DisplayConnectionError: 
 46          X_DISPLAY = None 
 47   
 48  LOCAL_HOME = os.path.normpath(os.path.expanduser('~')) 
 49  X2GO_SESSIONS_ROOTDIR = '.x2go' 
 50  X2GO_CLIENT_ROOTDIR = '.x2goclient' 
 51  X2GO_SSH_ROOTDIR = os.path.join('.x2go','.ssh') 
 52   
 53  # setting OS dependent variables 
 54  if X2GOCLIENT_OS == "Windows": 
 55      # on Windows we will use the current directory as ,,ROOTDIR'' which 
 56      # will normally be the application directory 
 57      ROOT_DIR = os.path.abspath(os.path.curdir) 
 58      ETC_DIR = os.path.join(ROOT_DIR, 'etc') 
 59      import win32api 
 60      CURRENT_LOCAL_USER = win32api.GetUserName() 
 61      X2GO_SSH_ROOTDIR = '.ssh' 
 62      SUPPORTED_SOUND = True 
 63      SUPPORTED_PRINTING = True 
 64      SUPPORTED_FOLDERSHARING = True 
 65      SUPPORTED_MIMEBOX = True 
 66      SUPPORTED_TELEKINESIS = False 
 67   
 68  elif X2GOCLIENT_OS == "Linux": 
 69      ROOT_DIR = '/' 
 70      ETC_DIR = os.path.join(ROOT_DIR, 'etc', 'x2goclient') 
 71      import getpass 
 72      CURRENT_LOCAL_USER = getpass.getuser() 
 73      X2GO_SSH_ROOTDIR = '.ssh' 
 74      SUPPORTED_SOUND = True 
 75      SUPPORTED_PRINTING = True 
 76      SUPPORTED_FOLDERSHARING = True 
 77      SUPPORTED_MIMEBOX = True 
 78      SUPPORTED_TELEKINESIS = True 
 79   
 80  elif X2GOCLIENT_OS == "Mac": 
 81      ROOT_DIR = '/' 
 82      ETC_DIR = os.path.join(ROOT_DIR, 'etc', 'x2goclient') 
 83      import getpass 
 84      CURRENT_LOCAL_USER = getpass.getuser() 
 85      X2GO_SSH_ROOTDIR = '.ssh' 
 86      SUPPORTED_SOUND = True 
 87      SUPPORTED_PRINTING = True 
 88      SUPPORTED_FOLDERSHARING = True 
 89      SUPPORTED_MIMEBOX = True 
 90      SUPPORTED_TELEKINESIS = False 
 91   
 92  else: 
 93      import exceptions 
94 - class OSNotSupportedException(exceptions.StandardError): pass
95 raise OSNotSupportedException('Platform %s is not supported' % platform.system()) 96 97 ## 98 ## backends of Python X2Go 99 ## 100 101 BACKENDS = { 102 'X2GoControlSession': { 103 'default': 'PLAIN', 104 'PLAIN': 'x2go.backends.control.plain', 105 }, 106 'X2GoTerminalSession': { 107 'default': 'PLAIN', 108 'PLAIN': 'x2go.backends.terminal.plain', 109 }, 110 'X2GoServerSessionInfo': { 111 'default': 'PLAIN', 112 'PLAIN': 'x2go.backends.info.plain', 113 }, 114 'X2GoServerSessionList': { 115 'default': 'PLAIN', 116 'PLAIN': 'x2go.backends.info.plain', 117 }, 118 'X2GoProxy': { 119 'default': 'NX3', 120 'NX3': 'x2go.backends.proxy.nx3', 121 }, 122 'X2GoSessionProfiles': { 123 'default': 'FILE', 124 'FILE': 'x2go.backends.profiles.file', 125 'GCONF': 'x2go.backends.profiles.gconf', 126 'HTTPBROKER': 'x2go.backends.profiles.httpbroker', 127 'SSHBROKER': 'x2go.backends.profiles.sshbroker', 128 'WINREG': 'x2go.backends.profiles.winreg', 129 }, 130 'X2GoClientSettings': { 131 'default': 'FILE', 132 'FILE': 'x2go.backends.settings.file', 133 'GCONF': 'x2go.backends.settings.gconf', 134 'WINREG': 'x2go.backends.settings.winreg', 135 }, 136 'X2GoClientPrinting': { 137 'default': 'FILE', 138 'FILE': 'x2go.backends.printing.file', 139 'GCONF': 'x2go.backends.printing.gconf', 140 'WINREG': 'x2go.backends.printing.winreg', 141 } 142 } 143 144 ## 145 ## X2Go Printing 146 ## 147 148 X2GO_SETTINGS_FILENAME = 'settings' 149 X2GO_SETTINGS_CONFIGFILES = [ 150 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'settings')), 151 os.path.normpath(os.path.join(ETC_DIR,X2GO_SETTINGS_FILENAME)), 152 ] 153 X2GO_PRINTING_FILENAME = 'printing' 154 X2GO_PRINTING_CONFIGFILES = [ 155 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'printing')), 156 os.path.normpath(os.path.join(ETC_DIR,X2GO_PRINTING_FILENAME)), 157 ] 158 X2GO_SESSIONPROFILES_FILENAME = 'sessions' 159 X2GO_SESSIONPROFILES_CONFIGFILES = [ 160 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'sessions')), 161 os.path.normpath(os.path.join(ETC_DIR,X2GO_SESSIONPROFILES_FILENAME)), 162 ] 163 X2GO_XCONFIG_FILENAME = 'xconfig' 164 X2GO_XCONFIG_CONFIGFILES = [ 165 os.path.normpath(os.path.join(LOCAL_HOME, X2GO_CLIENT_ROOTDIR, 'xconfig')), 166 os.path.normpath(os.path.join(ETC_DIR,X2GO_XCONFIG_FILENAME)), 167 ] 168 169 X2GO_CLIENTSETTINGS_DEFAULTS = { 170 'LDAP': { 171 'useldap': False, 172 'port': 389, 173 'server': 'localhost', 174 'port1': 0, 175 'port2': 0, 176 }, 177 'General': { 178 # clientport is not needed for Python X2Go 179 'clientport': 22, 180 'autoresume': True, 181 }, 182 'Authorization': { 183 'newprofile': True, 184 'suspend': True, 185 'editprofile': True, 186 'resume': True 187 }, 188 'trayicon': { 189 'enabled': True, 190 'mintotray': True, 191 'noclose': True, 192 'mincon': True, 193 'maxdiscon': True, 194 }, 195 } 196 X2GO_CLIENTPRINTING_DEFAULTS = { 197 'General': { 198 # showdialog will result in a print action that allows opening a print dialog box 199 'showdialog': False, 200 # if true, open a PDF viewer (or save as PDF file). If false, print via CUPS or print command 201 'pdfview': True, 202 }, 203 'print': { 204 # If false, print via CUPS. If true, run "command" to process the print job 205 'startcmd': False, 206 # print command for non-CUPS printing 207 'command': 'lpr', 208 # ignored in Python X2Go 209 'stdin': False, 210 # ignored in Python X2Go 211 'ps': False, 212 }, 213 'save': { 214 # a path relative to the user's home directory 215 'folder': 'PDF', 216 }, 217 'view': { 218 # If General->pdfview is true: 219 # if open is true, the PDF viewer command is executed 220 # if open is false, the incoming print job is saved in ~/PDF folder 221 'open': True, 222 # command to execute as PDF viewer 223 'command': 'xdg-open', 224 }, 225 'CUPS': { 226 # default print queue for CUPS, if print queue does not exist, the default 227 # CUPS queue is detected 228 'defaultprinter': 'PDF', 229 }, 230 } 231 if X2GOCLIENT_OS == 'Windows': 232 X2GO_CLIENTPRINTING_DEFAULTS['print'].update({'gsprint': os.path.join(os.environ['ProgramFiles'], 'GhostGum', 'gsview', 'gsprint.exe'), }) 233 234 235 if X2GOCLIENT_OS == 'Windows': 236 X2GO_CLIENTXCONFIG_DEFAULTS = { 237 'XServers': { 238 'known_xservers': ['VcXsrv_development', 'VcXsrv_shipped', 'VcXsrv', 'Xming', 'Cygwin-X', ], 239 }, 240 'Cygwin-X': { 241 'display': 'localhost:40', 242 'last_display': 'localhost:40', 243 'process_name': 'XWin.exe', 244 'test_installed': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'), 245 'run_command': os.path.join(os.environ['SystemDrive'], '\\', 'cygwin', 'bin', 'XWin.exe'), 246 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ], 247 }, 248 'VcXsrv': { 249 'display': 'localhost:40', 250 'last_display': 'localhost:40', 251 'process_name': 'vcxsrv.exe', 252 'test_installed': os.path.join(os.environ['ProgramFiles'], 'VcXsrv', 'vcxsrv.exe'), 253 'run_command': os.path.join(os.environ['ProgramFiles'], 'VcXsrv', 'vcxsrv.exe'), 254 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ], 255 }, 256 'VcXsrv_shipped': { 257 'display': 'localhost:40', 258 'last_display': 'localhost:40', 259 'process_name': 'vcxsrv.exe', 260 'test_installed': os.path.join(os.getcwd(), 'VcXsrv', 'vcxsrv.exe'), 261 'run_command': os.path.join(os.getcwd(), 'VcXsrv', 'vcxsrv.exe'), 262 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ], 263 }, 264 'VcXsrv_development': { 265 'display': 'localhost:40', 266 'last_display': 'localhost:40', 267 'process_name': 'vcxsrv.exe', 268 'test_installed': os.path.join(os.getcwd(), '..', 'pyhoca-contrib', 'mswin', 'vcxsrv-mswin', 'VcXsrv-1.15.2.2-xp+vc2013+x2go1_bin', 'vcxsrv.exe'), 269 'run_command': os.path.join(os.getcwd(), '..', 'pyhoca-contrib', 'mswin', 'vcxsrv-mswin', 'VcXsrv-1.15.2.2-xp+vc2013+x2go1_bin', 'vcxsrv.exe'), 270 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ], 271 }, 272 'Xming': { 273 'display': 'localhost:40', 274 'last_display': 'localhost:40', 275 'process_name': 'Xming.exe', 276 'test_installed': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'), 277 'run_command': os.path.join(os.environ['ProgramFiles'], 'Xming', 'Xming.exe'), 278 'parameters': [':40', '-clipboard', '-multiwindow', '-notrayicon', '-nowinkill', '-nounixkill', '-swcursor', ], 279 }, 280 } 281 else: 282 # make the variable available when building API documentation with epydoc 283 X2GO_CLIENTXCONFIG_DEFAULTS = {} 284 285 X2GO_GENERIC_APPLICATIONS = [ 'WWWBROWSER', 'MAILCLIENT', 'OFFICE', 'TERMINAL', ] 286 """X2Go's generic applications.""" 287 288 X2GO_SESSIONPROFILE_DEFAULTS = { 289 'autologin': True, 'autoconnect': False, 'autostart': False, 'setsessiontitle': False, 'sessiontitle': "", 290 'speed': 2, 'pack': '16m-jpeg', 'quality': 9, 291 'iconvto': 'UTF-8', 'iconvfrom': 'UTF-8', 'useiconv': False, 292 'usesshproxy': False, 'sshproxyhost': 'proxyhost.mydomain', 'sshproxyport': 22, 'sshproxyuser': '', 'sshproxykeyfile': '', 293 'sshproxytype': 'SSH', 'sshproxysameuser': False, 'sshproxysamepass': False, 'sshproxyautologin': True, 294 'uniquehostkeyaliases': False, 295 'useexports': True, 'restoreexports': False, 'fstunnel': True, 'export': {}, 296 'usemimebox': False, 'mimeboxextensions': '', 'mimeboxaction': 'OPEN', 297 'fullscreen': False, 'clipboard': 'both', 298 'width': 800,'height': 600, 'maxdim': False, 'dpi': 96, 'setdpi': False, 'xinerama': False, 'multidisp': False, 'display': 1, 299 'usekbd': True, 'layout': 'us', 'type': 'pc105/us', 'variant': '', 300 'sound': False, 'soundsystem': 'pulse', 'startsoundsystem': False, 'soundtunnel':True, 'defsndport':True, 'sndport':4713, 301 'name': 'NEW_PROFILE', 'icon': ':icons/128x128/x2gosession.png', 302 'host': ['server.mydomain'], 'user': CURRENT_LOCAL_USER, 'key': '', 'sshport': 22, 'krblogin': False, 'forwardsshagent': False, 303 'rootless': True, 'applications': X2GO_GENERIC_APPLICATIONS, 'command':'TERMINAL', 'published': False, 304 'directrdp': False, 'directrdpsettings': '', 'rdpclient': 'rdesktop', 'rdpport': 3389, 305 'rdpoptions': '-u X2GO_USER -p X2GO_PASSWORD', 'rdpserver': '', 306 'print': False, 307 'xdmcpserver': 'localhost', 308 } 309 """L{X2GoSessionProfiles} default values to fill a new session profile with.""" 310 ## 311 ## X2Go Proxy defaults 312 ## 313 314 # here is a list of NX 3.x compression methods, this is the "%"-hashed list that 315 # can also be used for printing in help texts, docs etc. 316 # The "%"-sign can be replaced by digits 0-9. 317 pack_methods_nx3_noqual = ['nopack','8','64','256','512','4k','32k','64k','256k','2m','16m', 318 '256-rdp','256-rdp-compressed','32k-rdp','32k-rdp-compressed','64k-rdp', 319 '64k-rdp-compressed','16m-rdp','16m-rdp-compressed', 320 'rfb-hextile','rfb-tight','rfb-tight-compressed', 321 '8-tight','64-tight','256-tight','512-tight','4k-tight','32k-tight', 322 '64k-tight','256k-tight','2m-tight','16m-tight', 323 '8-jpeg-%','64-jpeg','256-jpeg','512-jpeg','4k-jpeg','32k-jpeg', 324 '64k-jpeg','256k-jpeg','2m-jpeg','16m-jpeg-%', 325 '8-png-jpeg-%','64-png-jpeg','256-png-jpeg','512-png-jpeg','4k-png-jpeg', 326 '32k-png-jpeg','64k-png-jpeg','256k-png-jpeg','2m-png-jpeg','16m-png-jpeg-%', 327 '8-png-%','64-png','256-png','512-png','4k-png', 328 '32k-png','64k-png','256k-png','2m-png','16m-png-%', 329 '16m-rgb-%','16m-rle-%',] 330 """Available NX3 compression methods.""" 331 332 # use for printing on screen... 333 pack_methods_nx3_formatted=""" 334 \'%s\' 335 \'%s\' 336 \'%s\' 337 \'%s\' 338 \'%s\' 339 \'%s\' 340 \'%s\' 341 \'%s\' 342 \'%s\' 343 \'%s\' 344 \'%s\' 345 \'%s\' 346 \'%s\' 347 """ % ('\', \''.join(pack_methods_nx3_noqual[0:11]), \ 348 '\', \''.join(pack_methods_nx3_noqual[11:16]), \ 349 '\', \''.join(pack_methods_nx3_noqual[16:19]), \ 350 '\', \''.join(pack_methods_nx3_noqual[19:22]), \ 351 '\', \''.join(pack_methods_nx3_noqual[22:28]), \ 352 '\', \''.join(pack_methods_nx3_noqual[28:32]), \ 353 '\', \''.join(pack_methods_nx3_noqual[32:38]), \ 354 '\', \''.join(pack_methods_nx3_noqual[38:42]), \ 355 '\', \''.join(pack_methods_nx3_noqual[42:47]), \ 356 '\', \''.join(pack_methods_nx3_noqual[47:52]), \ 357 '\', \''.join(pack_methods_nx3_noqual[52:57]), \ 358 '\', \''.join(pack_methods_nx3_noqual[57:62]), \ 359 '\', \''.join(pack_methods_nx3_noqual[62:])) 360 361 # pack_methods_nx3 is the complete list of NX3 pack methods that can be used to check options 362 # against 363 pack_methods_nx3 = [ m for m in pack_methods_nx3_noqual if "%" not in m ] 364 for meth in [ m for m in pack_methods_nx3_noqual if "%" in m ]: 365 pack_methods_nx3 += [ meth.replace('%','%s' % str(i)) for i in range(0,10) ] 366 pack_methods_nx3.sort() 367 ## 368 ## X2Go session defaults 369 ## 370 371 X2GO_DESKTOPSESSIONS={ 372 'CINNAMON': 'cinnamon', 373 'KDE': 'startkde', 374 'GNOME': 'gnome-session', 375 'MATE': 'mate-session', 376 'XFCE': 'xfce4-session', 377 'LXDE': 'startlxde', 378 'LXQt': 'startlxqt', 379 'TRINITY': 'starttrinity', 380 'UNITY': 'unity', 381 } 382 """A dictionary with meta-commands for X2Go's window manager sessions.""" 383 384 ## 385 ## X2Go SFTP server defaults 386 ## 387 388 RSAKEY_STRENGTH = 1024 389 RSAHostKey = paramiko.RSAKey.generate(RSAKEY_STRENGTH) 390 """\ 391 An RSA host key for this client session. Python X2Go does not use the 392 system's host key but generates its own host key for each running 393 application instance. 394 395 """ 396 397 X2GO_PRINT_ACTIONS = { 398 'PDFVIEW': 'X2GoPrintActionPDFVIEW', 399 'PDFSAVE': 'X2GoPrintActionPDFSAVE', 400 'PRINT': 'X2GoPrintActionPRINT', 401 'PRINTCMD': 'X2GoPrintActionPRINTCMD', 402 'DIALOG': 'X2GoPrintActionDIALOG', 403 } 404 """Relating print action names and classes.""" 405 406 DEFAULT_PDFVIEW_CMD = 'xdg-open' 407 """Default PDF viewer command for Linux systems (PDFVIEW print action).""" 408 DEFAULT_PDFSAVE_LOCATION = 'PDF' 409 """Default location for saving PDF files (PDFSAVE print action).""" 410 DEFAULT_PRINTCMD_CMD = 'lpr' 411 """Default command for the PRINTCMD print action.""" 412 413 X2GO_MIMEBOX_ACTIONS = { 414 'OPEN': 'X2GoMIMEboxActionOPEN', 415 'OPENWITH': 'X2GoMIMEboxActionOPENWITH', 416 'SAVEAS': 'X2GoMIMEboxActionSAVEAS', 417 } 418 """Relating MIME box action names and classes.""" 419 420 X2GO_MIMEBOX_EXTENSIONS_BLACKLIST = [ 421 'LOCK', 'SYS', 'SWP', 422 'EXE', 'COM', 'CMD', 'PS1', 'PS2', 'BAT', 423 'JS', 'PY', 'PL', 'SH', 424 ] 425 """Black-listed MIME box file extenstions.""" 426 427 # X2Go desktop sharing 428 X2GO_SHARE_VIEWONLY=0 429 """Constant representing read-only access to shared desktops.""" 430 X2GO_SHARE_FULLACCESS=1 431 """Constant representing read-write (full) access to shared desktops.""" 432 433 PUBAPP_MAX_NO_SUBMENUS=10 434 """Less than ten applications will not get rendered into submenus.""" 435