The branch, twofactorauth has been updated via 62cdc5c76c212bbbf0086717f56d147107f0f8d1 (commit) from 3734cd9ddc229a85f699835de6d358294916fe8f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: x2go/printing.py | 5 +- x2go/profiles.py | 382 ++++++++++++++++++++++++++++++++++++++++++++++++++---- x2go/settings.py | 27 ---- 3 files changed, 358 insertions(+), 56 deletions(-) The diff of changes is: diff --git a/x2go/printing.py b/x2go/printing.py index f2e4cbe..706228f 100644 --- a/x2go/printing.py +++ b/x2go/printing.py @@ -37,8 +37,9 @@ import subprocess import types import threading import gevent -import ConfigParser +import inifiles import cStringIO +import ConfigParser if sys.platform == 'win32': import win32api @@ -52,7 +53,7 @@ import utils _PRINT_ENV = os.environ.copy() -class X2goClientPrinting(ConfigParser.SafeConfigParser): +class X2goClientPrinting(inifiles.X2goProcessIniFile): """\ STILL UNDOCUMENTED """ diff --git a/x2go/profiles.py b/x2go/profiles.py index c7c0922..04568a8 100644 --- a/x2go/profiles.py +++ b/x2go/profiles.py @@ -22,31 +22,359 @@ X2goClientSessionProfile class - managing x2goclient session profiles. """ __NAME__ = 'x2gosessionprofiles-pylib' -# modules -import os -import ConfigParser - -class X2goClientSessionProfile(object): - """\ - NOT IMPLEMENTED YET - """ - def __init__(self): - pass - -class X2goClientSessionProfiles(ConfigParser.SafeConfigParser): - """\ - NOT IMPLEMENTED YET - """ - def load(self): - """\ - NOT IMPLEMENTED YET - """ - pass - - def list(self): - """\ - NOT IMPLEMENTED YET - """ - pass - +#import os +#import ConfigParser +#import types +#import exceptions +#class _processINI(object): +# """ +# Base class to process the different ini files used in x2go. +# Primarily used to standardize the content of the +# ini file. +# If entries are omitted in the file, they are filled with +# default values, so the resulting objects always contain +# the same fields +# """ +# def __init__(self, fileName): +# """\ +# STILL UNDOCUMENTED +# """ +# self.writeconfig = False +# self.iniConfig = ConfigParser.SafeConfigParser() +# if fileName and os.path.exists(fileName): +# self.iniConfig.read(fileName) +# +# +# def fillDefaultsSection(self): +# """\ +# STILL UNDOCUMENTED +# """ +# for section, sectionvalue in self.defaultValues.items(): +# for key, value in sectionvalue.items(): +# if self.iniConfig.has_option(section,key): continue +# if not self.iniConfig.has_section(section): +# self.iniConfig.add_section(section) +# self.storeValueTypes(section, key, value) +# +# +# def updValue(self, section, key, value): +# """\ +# STILL UNDOCUMENTED +# """ +# if not self.iniConfig.has_section(section): +# self.iniConfig.add_section(section) +# self.storeValueTypes(section, key, value) +# self.writeconfig = True +# +# +# def storeValueTypes(self, section, key, value): +# """\ +# STILL UNDOCUMENTED +# """ +# if type(value) is types.StringType: +# self.iniConfig.set(section,key,value) +# elif type(value) is types.BooleanType: +# if value: +# self.iniConfig.set(section,key,'1') +# else: +# self.iniConfig.set(section,key,'0') +# else: +# self.iniConfig.set(section,key,str(value)) +## +# def writeIni(self): +# """\ +# STILL UNDOCUMENTED +# """ +# if self.writeconfig: +# fd = open(self.fileName, 'wb') +# self.iniConfig.write(fd) +# fd.close() +# self.writeconfig = False +# +# def getValue(self, section, key, getType=None): +# """\ +# STILL UNDOCUMENTED +# """ +# if self.iniConfig.has_option(section, key): +# if getType is None: +# return self.iniConfig.get(section, key) +# elif getType is types.BooleanType: +# return self.iniConfig.getboolean(section, key) +# elif getType is types.IntType: +# return self.iniConfig.getint(section, key) +# +# def bldSessionObj(self): +# """ +# This routine flattens the items making them simple +# object members +# +# Note, it assumes the option is unique within the config! +# """ +# for section in self.iniConfig.sections(): +# for option in self.iniConfig.options(section): +# if section in self.defaultValues and option in self.defaultValues[section]: +# setattr(self, option, self.getValue(section, option, type(self.defaultValues[section][option]))) +# else: +# setattr(self, option, self.getValue(section, option)) +# +# +#class X2goClientSettings(_processINI): +# """ +# Settings object that contains all data that is generally necessary +# """ +# defaultValues = { 'LDAP':{'useldap':False,'port':389,'server':'localhost','port1':0,'port2':0}, \ +# 'General':{'clientport':22,'autoresume':True}, \ +# 'Authorization': {'newprofile':True,'suspend':True,'editprofile':True,'resume':True} +# } +# def __init__(self, fileName=None): +# """\ +# STILL UNDOCUMENTED +# """ +# if fileName is None: +# fileName = os.path.normpath(os.path.expanduser('~/.x2goclient/settings')) +# _processINI.__init__(self, fileName) +# self.fillDefaultsSection() +# self.bldSessionObj() +# +# +#class X2goClientSessionProfiles(_processINI): +# """ +# Session object that contains several sessionProfiles that contain all data necessary to open the connection with +# an x2go server +# """ +# defaultValues = \ +# {'speed':2,'pack':'16m-jpeg','quality':9,'fstunnel':True,'export':'"/home/dick/Documenten:1;"','fullscreen':False,'width':800,'height':600,'dpi':96, +# 'setdpi':False,'usekbd':True,'layout':'us','type':'pc105/us','sound':False,'soundsystem':'pulse','startsoundsystem':True,'soundtunnel':True, +# 'defsndport':True,'sndport':4713, 'printing':True,'name':None,'icon':':icons/128x128/x2gosession.png','host':None,'user':None, 'key':None, +# 'sshport':22,'rootless':True,'applications':'dummy, WWWBROWSER, MAILCLIENT, OFFICE, TERMINAL','command':'dummy','rdpoptions':None, +# 'rdpserver':None,'default':False,'connected':False} +# def __init__(self, fileName=None): +# """\ +# STILL UNDOCUMENTED +# """ +# if fileName is None: +# fileName = os.path.normpath(os.path.expanduser('~/.x2goclient/sessions')) +# _processINI.__init__(self, fileName) +# self.SessionProfiles = self.iniConfig.sections() +# for section in self.SessionProfiles: +# for key, sectionvalue in self.defaultValues.items(): +# if not self.iniConfig.has_option(section,key): +# self.storeValueTypes(section, key, sectionvalue) +# +# def getSection(self, section): +# """\ +# STILL UNDOCUMENTED +# """ +# return self.iniConfig.items(section) +# +# def newProfile(self, name, **kw): +# """\ +# STILL UNDOCUMENTED +# """ +# for key, value in kw.items(): +# if key in defaultValues: +# self.updValue(name, key, value) +# else: +# raise exceptions.X2goProfileException('Keyword %s not supported in profile' % key) +# +# for key, value in defaultValues.items(): +# if key in kw: continue +# self.storeValueTypes(name, key, value) +# +# +#class X2goSingleSessionProfile(object): +# """\ +# STILL UNDOCUMENTED +# """ +# +# def __init__(self, prof, profiles): +# """\ +# STILL UNDOCUMENTED +# """ +# self.prof = prof +# self.profiles = profiles +# self.session_uuid = None +# self.showConfigScreen = False +# self.bldSessionObj() +# if self.host is None: +# self.showConfigScreen = True +# +# +# def bldSessionObj(self): +# """\ +# STILL UNDOCUMENTED +# """ +# for option in self.profiles.iniConfig.options(self.prof): +# if self.prof in self.profiles.defaultValues and option in self.profiles.defaultValues[self.prof]: +# setattr(self, option, self.profiles.getValue(self.prof, option, type(self.profiles.defaultValues[self.prof][option]))) +# else: +# setattr(self, option, self.profiles.getValue(self.prof, option)) +# +# +# def updConfig(self): +# """\ +# STILL UNDOCUMENTED +# """ +# for key, retType in self.fieldList: +# self.updValue(self.prof, key, self.__dict__[key]) +# +# +# def Connect(self, parent): +# """\ +# STILL UNDOCUMENTED +# """ +# printing = parent.printProfile +# geometry = str(self.width) + 'x' + str(self.height) +# self.c = x2go.X2goClient(logger=parent.liblogger) +# self.session_uuid = c.register_session(self.host, port=self.sshport, +# username=self.user, +# password=self.password, +# key_filename=self.key, +# add_to_known_hosts=self.add_to_known_hosts, +# profile_name = self.name, +# session_type=self.session_type, +# link=self.link, +# geometry=geometry, +# pack=self.pack, +# cache_type=self.cache_type, +# kblayout=self.layout, +# kbtype=self.type, +# snd_system=self.sound, +# printing=self.printing, +# print_action=printing.print_action, +# print_action_args=printing.print_action_args, +# cmd=printing.command) +# self.c.session_start(session_uid) +# self.profiles.updValue(self.prof, 'connected', True) +# self.connected = True +# self.profiles.writeIni() +# +# def Resume(self, parent, printing): +# """\ +# STILL UNDOCUMENTED +# """ +# pass +# +# +# def DisConnect(self): +# """\ +# STILL UNDOCUMENTED +# """ +# self.profiles.updValue(self.prof, 'connected', True) +# self.connected = False +# self.profiles.writeIni() +# +# +# def isAlive(self): +# """\ +# STILL UNDOCUMENTED +# """ +# return self.c.session_ok(self.session_uuid) +# +# +#class X2goClientSessionProfiles(object): +# """\ + # STILL UNDOCUMENTED +# """ +# +# def __init__(self): +# """\ +# STILL UNDOCUMENTED +# """ +# self.x2goprofs = [] +# self.there_is_a_default = 0 +# self.profiles = SessionProfiles() + # for prof in self.profiles.SessionProfiles: +# newSession = SingleProfile(prof, self.profiles) +# if newSession.default: +# self.x2goprofs.insert(0,newSession) +# self.there_is_a_default += 1 +# else: +# self.x2goprofs.append(newSession) +# if len(self.profiles.SessionProfiles): +# self.current_profile = self.x2goprofs[0] +# +# def Append(self, name, **kw): +# """\ +# STILL UNDOCUMENTED +# """ +# if self.profileExists(name): +# raise exceptions.X2goProfileException('Profile %s already exists' % name) +# else: +# self.profiles.newProfile(name, kw) +# self.x2goprofs.append(SingleProfile(name, self.profiles)) +# +# def writeIni(self): +# """\ +# STILL UNDOCUMENTED +# """ +# for s in self.x2goprofs: +# s.updConfig() +# self.profiles.writeIni() +# +# def defaultAvailable(self): +# """\ +# STILL UNDOCUMENTED +# """ +# return self.there_is_a_default == 1 +# +# def profileExists(self, name): +# """\ + # STILL UNDOCUMENTED +# """ +# for profile in self.x2goprofs: +# if profile.prof == name or profile.name == name: +# self.current_profile = profile +# return True +# return False +# +# def runningSessions(self): +# """\ +# STILL UNDOCUMENTED +## """ +# running = [] +# for idx, profs in enumerate(self.profiles.iniConfig.sections()): +# connected = self.profiles.getValue(profs, 'connected', getType='bool') +# if connected: +# running.append(x2goprofs[idx]) +# return running +# +# def suspendedSessions(self): +# """\ +# STILL UNDOCUMENTED +# """ +# running = self.runningSessions() +# suspended = [] +# for idx, run in enumerate(running): +# if running.isAlive(): continue +# suspended.appended(run) +# return suspended +# +# def anyRunningSessions(self): +# """\ +# STILL UNDOCUMENTED +# """ +# return len(self.runningSessions()) > 0 +# +# def listAllAvailableSessions(self): +# """\ +# STILL UNDOCUMENTED +# """ +# availableSessions = [] +# for idx, profs in enumerate(self.profiles.iniConfig.sections()): +# availableSessions.append([self.profiles.getValue(profs, 'name'), self.profiles.getValue(profs, 'connected', getType='bool')]) +# return availableSessions +# +# def listNonRunningProfiles(self): +# """\ +# STILL UNDOCUMENTED +# """ +# nonrunning = [] +# for idx, profs in enumerate(self.profiles.iniConfig.sections()): +# connected = self.profiles.getValue(profs, 'connected', getType='bool') +# if not connected: +# nonrunning.append(self.profiles.getValue(profs,'name')) +# return nonrunning +# +# \ No newline at end of file diff --git a/x2go/settings.py b/x2go/settings.py index 49a7911..3c01824 100644 --- a/x2go/settings.py +++ b/x2go/settings.py @@ -44,30 +44,3 @@ class X2goClientSettings(ConfigParser.SafeConfigParser): def load(self): pass -class X2goClientPrinting(ConfigParser.SafeConfigParser): - """\ - NOT IMPLEMENTED YET - """ - def __init__(self, config_files=DEFAULT_PRINTING_CONFIGS, *args, **kwargs): - """\ - STILL UNDOCUMENTED - """ - self.config_files = config_files - ConfigParser.SafeConfigParser.__init__(self, *args, **kwargs) - - - def load(self): - """\ - STILL UNDOCUMENTED - """ - print self.read(self.config_files) - - def show(self): - """\ - STILL UNDOCUMENTED - """ - stdout = StringIO.cStringIO() - self.write(stdout) - print stdout.read() - - hooks/post-receive -- python-x2go.git (Python X2Go Client API) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "python-x2go.git" (Python X2Go Client API).