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

Source Code for Module x2go.defaults

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