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

Source Code for Module x2go.defaults

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