Beispiel #1
0
    def about(self, unused_widget, unused_data=None):
        """
		create and show the about dialog
		"""
        dlg = gtk.AboutDialog()
        dlg.set_title(_("About Persy"))

        # retrieving the installed version of persy
        VERSION = _("undefined")
        try:
            p = PersyHelper()
            VERSION = p.getSoftwareVersion("persy")
            if not VERSION:
                VERSION = _("undefined")
        except Exception as e:
            pass
        dlg.set_version(VERSION)
        dlg.set_program_name("persy")
        dlg.set_comments(_("personal synchronization"))
        try:
            dlg.set_license(open(self.config.getAttribute("LICENSE_FILE")).read())
        except Exception as e:
            dlg.set_license(_("Sorry, i have a problem finding/reading the licence"))
            self.log.warn(str(e))

        dlg.set_authors(["Dennis Schwertel <*****@*****.**>", "Rafael Römhild <*****@*****.**>"])
        dlg.set_icon_from_file(self.config.getAttribute("LOGO"))
        dlg.set_logo(gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute("LOGO"), 128, 128))

        def close(w, res):
            if res == gtk.RESPONSE_CANCEL:
                w.hide()

        dlg.connect("response", close)
        dlg.show()
Beispiel #2
0
	def __init__(self, configfile = None):
		"""
		the the static attributes and parses the configuration file
		"""
		self.attributes = {}
		self.p = PersyHelper()

		#host stuff
		self.attributes['DIST'] = platform.dist() # ('Ubuntu', '9.10', 'karmic')

		# files and dirs used by persy
		self.attributes['USERHOME'] = os.environ["HOME"]
		self.attributes['LOCALSSHDIR']=os.path.join(self.attributes['USERHOME'],'.ssh')
		self.attributes['PERSY_DIR'] = os.path.join(self.attributes['USERHOME'], '.persy')
		self.attributes['GIT_DIR'] = os.path.join(self.attributes['PERSY_DIR'],'git')
		self.attributes['GIT_WORK_TREE'] =self.attributes['USERHOME']
		self.attributes['GIT_LOCKFILE'] = os.path.join(self.attributes['GIT_DIR'],'index.lock')
		self.attributes['LOGFILE']=os.path.join(self.attributes['PERSY_DIR'],'default.log')
		self.attributes['LOGFILE_GIT']=os.path.join(self.attributes['PERSY_DIR'],'git.log')
		self.attributes['GITIGNOREFILE']=os.path.join(self.attributes['GIT_DIR'], 'info','exclude')
		self.attributes['EXAMPLECONFIG']='/usr/share/persy/example_config'
		self.attributes['GLADEFILE']='/usr/share/persy/lib/persy.glade'
		self.attributes['VERSIONFILE']='/usr/share/persy/assets/VERSION'
		self.attributes['HTMLDOCFILE']='/usr/share/doc/persy/index.html'
		self.attributes['PERSY_BIN']='/usr/bin/persy'

		#set the config file to default or a new one
		if configfile:
			self.attributes['CONFIGFILE']=configfile
		else:
			self.attributes['CONFIGFILE']=os.path.join(self.attributes['PERSY_DIR'],'config')

		#path to some files and icons
		self.attributes['ICON_IDLE'] = '/usr/share/persy/assets/persy.svg'
		self.attributes['ICON_OK'] = '/usr/share/persy/assets/persy_ok.svg'
		self.attributes['ICON_UNSYNCED'] = '/usr/share/persy/assets/persy_unsynced.svg'
		self.attributes['ICON_UNTRACKED'] = '/usr/share/persy/assets/persy_untracked.svg'
		self.attributes['ICON_WARN'] = '/usr/share/persy/assets/persy_warn.svg'
		self.attributes['ICON_ERROR'] = '/usr/share/persy/assets/persy_error.svg'


		#logo depends on DIST!
		if self.attributes['DIST'][0] == 'Ubuntu':
			self.attributes['LOGO'] = '/usr/share/persy/assets/persy.svg'
		elif self.attributes['DIST'][0] == 'LinuxMint':
			self.attributes['LOGO'] = '/usr/share/persy/assets/dist/persy_linuxmint.svg'
		elif self.attributes['DIST'][0] == 'fedora':
			self.attributes['LOGO'] = '/usr/share/persy/assets/dist/persy_fedora.svg'
		else:
			self.attributes['LOGO'] = '/usr/share/persy/assets/persy.svg'

		#path to the license file
		self.attributes['LICENSE_FILE'] = '/usr/share/persy/assets/GPL-2'

		#git variables used by persy
		self.attributes['SERVER_NICK']='origin'
		self.attributes['BRANCH']='master'

		#default config entries
		self.attributes['DEFAULT_LOCAL_SLEEP'] = 5
		self.attributes['DEFAULT_REMOTE_SLEEP'] = 300
		self.attributes['DEFAULT_REMOTE_HOSTNAME'] = ''
		self.attributes['DEFAULT_REMOTE_PORT'] = 22
		self.attributes['DEFAULT_REMOTE_PATH'] = ''

		try:
			#read the configuration
			self.attributes['DEFAULT_CONFIG']= open(self.attributes['EXAMPLECONFIG']).read()
			#replace the placeholder with the configuration values
			self.attributes['DEFAULT_CONFIG'] = self.attributes['DEFAULT_CONFIG'] % self.attributes
		except IOError as e:
			print str(e)

		#xterm terminal
		self.attributes['XTERM'] = "xterm"
		
		#fortune	
		self.attributes['FORTUNE'] = "fortune"

		#autoshare
		self.attributes['AUTOSHARE'] = "autoshare"

		#the default gui git browser
		self.attributes['GITGUI']=["gitk", "qgit"] #possible browsers

		if not os.path.exists(self.attributes['CONFIGFILE']):
			if not os.path.exists(self.attributes['PERSY_DIR']):
				os.mkdir(self.attributes['PERSY_DIR'])
			with open(self.attributes['CONFIGFILE'], "w+") as f:
				f.write(self.attributes['DEFAULT_CONFIG'])

		config = ConfigObj(self.attributes['CONFIGFILE'])

		#config check if everything is ok
		#================================
		#general GIT_DIR
		if not config['general'].has_key('gitdir') or not config['general']['gitdir']:
			config['general']['gitdir'] = self.attributes['GIT_DIR']

		#general GIT_WORK_TREE
		if not config['general'].has_key('gitworkdir') or not config['general']['gitworkdir']:
			config['general']['gitworktree'] = self.attributes['GIT_WORK_TREE']

		#general name
		if not config['general'].has_key('name') or not config['general']['name']:
			config['general']['name'] = 'default'

		#general mail
		if not config['general'].has_key('mail') or not config['general']['mail']:
			config['general']['name'] = 'mail'
	
		#general fortune
		if not config['general'].has_key('fortune'):
			config['general']['fortune'] = False
		if type(config['general']['fortune']) is str and config['general']['fortune'].lower()  == 'true':
			config['general']['fortune'] = True
		if not type(config['general']['fortune']) is bool:
			config['general']['fortune'] = False

		#general create_gui_indicator
		#flag to create an app indicator. default is True! 
		if not config['general'].has_key('create_gui_indicator'):
			config['general']['create_gui_indicator'] = True
		if type(config['general']['create_gui_indicator']) is str and config['general']['create_gui_indicator'].lower()  == 'false':
			config['general']['create_gui_indicator'] = False
		if not type(config['general']['create_gui_indicator']) is bool:
			config['general']['create_gui_indicator'] = True
		
		#general create_gui_statusicon
		#flag to create a status icon. default is False. 
		#Will still try to create a status icon if indicator fails! 
		if not config['general'].has_key('create_gui_statusicon'):
			config['general']['create_gui_statusicon'] = False
		if type(config['general']['create_gui_statusicon']) is str and config['general']['create_gui_statusicon'].lower()  == 'true':
			config['general']['create_gui_statusicon'] = True
		if not type(config['general']['create_gui_statusicon']) is bool:
			config['general']['create_gui_statusicon'] = False
		
	
	    	#general autoshare
		if not config['general'].has_key('autoshare'):
			config['general']['autoshare'] = False
		if type(config['general']['autoshare']) is str and config['general']['autoshare'].lower()  == 'true':
			config['general']['autoshare'] = True
		if not type(config['general']['autoshare']) is bool:
			config['general']['autoshare'] = False

		#general gitgui
		if not config['general'].has_key('prefgitbrowser'):
			config['general']['prefgitbrowser'] = ""
			for gitbrowser in self.attributes['GITGUI']:
				if self.p.getSoftwareVersion(gitbrowser):
					config['general']['prefgitbrowser'] = gitbrowser
					break
		if type(config['general']['prefgitbrowser']) is str:
			if config['general']['prefgitbrowser'].lower() in self.attributes['GITGUI'] and self.p.getSoftwareVersion(config['general']['prefgitbrowser']):
				config['general']['prefgitbrowser'] = config['general']['prefgitbrowser'].lower()
			else:
				config['general']['prefgitbrowser'] = ""
				for gitbrowser in self.attributes['GITGUI']:
					if self.p.getSoftwareVersion(gitbrowser):
						config['general']['prefgitbrowser'] = gitbrowser
						break
		if not type(config['general']['prefgitbrowser']) is str:
			#config is strange?! set it to the first possible prowser
			config['general']['prefgitbrowser'] = self.attributes['GITGUI'][0]


		#local sleep
		if not config['local'].has_key('sleep') or not config['local']['sleep']:
			config['local']['sleep'] = self.attributes['DEFAULT_LOCAL_SLEEP']

		if not type(config['local']['sleep']) is int:
			try:
				config['local']['sleep'] = int(config['local']['sleep'])
			except Exception as e:
				config['local']['sleep'] = self.attributes['DEFAULT_LOCAL_SLEEP']

		#local watched
		if not config['local'].has_key('watched') or not config['local']['watched']:
			config['local']['watched'] = []

		if type(config['local']['watched']) is str:
			config['local']['watched'] = [config['local']['watched']]

		if not type(config['local']['watched']) is list:
			config['local']['watched'] = []
		#remove spaces
		config['local']['watched'] = self.p.striplist(config['local']['watched'])

		#local maxfilesize
		if not config['local'].has_key('maxfilesize') or not type(config['local']['maxfilesize']) is str:
			config['local']['maxfilesize'] = 0
		if not type(config['local']['maxfilesize']) is int:
			try:
				config['local']['maxfilesize'] = int(config['local']['maxfilesize'])
			except Exception as e:
				config['local']['maxfilesize'] = 0

		#local exclude
		if not config['local'].has_key('exclude'):
			config['local']['exclude']=[]
		if type(config['local']['exclude']) is str:
			config['local']['exclude'] = [config['local']['exclude']]
		if not type(config['local']['exclude']) is list:
			config['local']['exclude'] = []
		#remove spaces
		config['local']['exclude'] = self.p.striplist(config['local']['exclude'])

		#remote use_remote
		if not config['remote'].has_key('use_remote'):
			config['remote']['use_remote'] = False
		if type(config['remote']['use_remote']) is str and config['remote']['use_remote'].lower()  == 'true':
			config['remote']['use_remote'] = True
		if not type(config['remote']['use_remote']) is bool:
			config['remote']['use_remote'] = False

		#remote sleep
		if not config['remote'].has_key('sleep') or not config['remote']['sleep']:
			config['remote']['sleep'] = self.attributes['DEFAULT_REMOTE_SLEEP']

		if not type(config['remote']['sleep']) is int:
			try:
				config['remote']['sleep'] = int(config['remote']['sleep'])
			except Exception as e:
				config['remote']['sleep'] = self.attributes['DEFAULT_REMOTE_SLEEP']

		#remote hostname
		if not config['remote'].has_key('hostname') or not type(config['remote']['hostname']) is str:
			config['remote']['hostname'] = self.attributes['DEFAULT_REMOTE_HOSTNAME']
			
		#remote port
		if not config['remote'].has_key('port') or not config['remote']['port']:
			config['remote']['port'] = self.attributes['DEFAULT_REMOTE_PORT']

		#remote username
		if not config['remote'].has_key('username') or not type(config['remote']['username']) is str:
			config['remote']['username'] = getpass.getuser() #if not set, use the current

		#remote path
		if not config['remote'].has_key('path') or not type(config['remote']['path']) is str:
			config['remote']['path'] = self.attributes['DEFAULT_REMOTE_PATH']


		#use gitsvn
		if not config['remote'].has_key('use_gitsvn'):
			config['remote']['use_gitsvn'] = False
		if type(config['remote']['use_gitsvn']) is str and config['remote']['use_gitsvn'].lower()  == 'true':
			config['remote']['use_gitsvn'] = True
		if not type(config['remote']['use_gitsvn']) is bool:
			config['remote']['use_gitsvn'] = False


		self.config = config
Beispiel #3
0
	def __init__(self, config, log, gtkcore):
	
		"""
		 *   builds the settings menu
		 *   does the localization of the gui
		 *   connects all buttons to the used actions
		"""

		#used do distinguish hboxes for watched entries
		self.hboxcounter = 0;

		self.config = config
		self.log = log
		self.gtkcore = gtkcore
		self.helper = PersyHelper()


		self.wTree = gtk.glade.XML(self.config.getAttribute('GLADEFILE'), 'window1')
		self.wTree.get_widget("window1").set_icon_from_file(self.config.getAttribute('LOGO'))
		self.wTree.get_widget("window1").set_title(_("persy settings"))

		self.wTree.get_widget("buttonSave").connect("clicked", self.save)
		self.wTree.get_widget("buttonSave").set_label(_("save"))


		textGeneralName = self.wTree.get_widget('labelGeneral')
		textGeneralName.set_label(_("general"))

		textGeneralName = self.wTree.get_widget('labelLocal')
		textGeneralName.set_label(_("backup"))

		textGeneralName = self.wTree.get_widget('labelRemote')
		textGeneralName.set_label(_("synchronization"))

		textGeneralName = self.wTree.get_widget('labelDevel')
		textGeneralName.set_label(_("administration"))

		#general configuration

		textGeneralName = self.wTree.get_widget('labelCategoryPersonal')
		textGeneralName.set_label('<b>'+_("personal information")+'</b>')

		textGeneralName = self.wTree.get_widget('labelGeneralName')
		textGeneralName.set_label(_("name"))

		textGeneralName = self.wTree.get_widget('textGeneralName')
		textGeneralName.set_text(config['general']['name'])
		textGeneralName.set_tooltip_text(_("username to distinguish different users for one share"))


		textGeneralName = self.wTree.get_widget('labelGeneralMail')
		textGeneralName.set_label(_("mail"))

		textGeneralName = self.wTree.get_widget('textGeneralMail')
		textGeneralName.set_text(config['general']['mail'])
		textGeneralName.set_tooltip_text(_("email to distinguish different users for one share"))

		textGeneralName = self.wTree.get_widget('labelCategoryAdvanced')
		textGeneralName.set_label('<b>'+_("advanced")+'</b>')

		a = autorun()
		textGeneralName = self.wTree.get_widget('checkGeneralAutostart')
		textGeneralName.set_active(a.exists('persy'))
		textGeneralName.set_label(_("start persy on login"))


		textGeneralName = self.wTree.get_widget('checkGeneralFortune')
		textGeneralName.set_active(config['general']['fortune'])
		textGeneralName.set_label(_("use fortune messages in the git commit"))
		
		if self.helper.which(config.getAttribute('FORTUNE')):
			textGeneralName.set_sensitive(True)
		else:
			textGeneralName.set_sensitive(False)
		
		textGeneralName = self.wTree.get_widget('checkGeneralAutoshare')
		textGeneralName.set_active(config['general']['autoshare'])
		textGeneralName.set_tooltip_text(_("if this is checked, all the computers in a sync will share the configuration file"))
		textGeneralName.set_label(_("share the configuration file") + _('(experimental)'))
		textGeneralName.set_sensitive(config['remote']['use_remote'])

		textGeneralName = self.wTree.get_widget('labelGeneralGitBrowser')
		textGeneralName.set_label(_("default git browser"))

		textGeneralName = self.wTree.get_widget('comboboxGeneralGitBrowser')

		for browser in self.config.getAttribute('GITGUI'):
			version = self.helper.getSoftwareVersion(browser)
			if version:
				textGeneralName.insert_text(0,browser)
				if self.config['general']['prefgitbrowser'] == browser:
					textGeneralName.set_active(0)
		textGeneralName.set_tooltip_text(_("the prefered git browser for browsing the local persy repository"))

		#local configuration
		textGeneralName = self.wTree.get_widget('labelLocalWatched')
		textGeneralName.set_label('<b>'+_("monitored folders in persy")+'</b>')

		for watched in config['local']['watched']:
			self.addWatchedEntry(None, watched)

		button = self.wTree.get_widget('buttonAddWatchedEntry')
		button.connect("clicked", self.addWatchedEntry, '')

		textGeneralName = self.wTree.get_widget('labelCategorySyncOptions')
		textGeneralName.set_label('<b>'+_("backup options")+'</b>')

		textGeneralName = self.wTree.get_widget('labelLocalSleep')
		textGeneralName.set_label(_("time to wait for a backup after an file action (in seconds)"))

		textGeneralName = self.wTree.get_widget('spinLocalSleep')
		textGeneralName.set_value(int(config['local']['sleep']))
		textGeneralName.set_tooltip_text(_("time to wait for a backup after an file action (in seconds)"))


		textGeneralName = self.wTree.get_widget('labelCategoryExclude')
		textGeneralName.set_label('<b>'+_("exclude options")+'</b>')

		textGeneralName = self.wTree.get_widget('labelLocalFilesize')
		textGeneralName.set_label(_("maximal allowed size of files (in bytes)"))

		textGeneralName = self.wTree.get_widget('spinLocalFilesize')
		textGeneralName.set_value(int(config['local']['maxfilesize']))
		textGeneralName.set_tooltip_text(_("all files larger than this value will be ignored"))


		textGeneralName = self.wTree.get_widget('labelLocalExclude')
		textGeneralName.set_label(_("exclude all files matching these regular expressions"))

		textGeneralName = self.wTree.get_widget('textLocalExclude')
		textGeneralName.set_text(", ".join(config['local']['exclude']))
		textGeneralName.set_tooltip_text(_("the expressions are seperated by a comma"))

		textGeneralName = self.wTree.get_widget('labelCategoryExclude1')
		textGeneralName.set_label('<b>'+_("excluded submodules / directories")+'</b>')

		textGeneralName = self.wTree.get_widget('label1')
		textGeneralName.set_text(_("these directories are git submodules and can not be tracked with persy")+':')


		textGeneralName = self.wTree.get_widget('label2')
		submodules = self.gtkcore.get_submodules()
		if submodules:
			textGeneralName.set_text("\n".join(submodules))
		else:
			textGeneralName.set_text("none!")

		#remote configuration
		textGeneralName = self.wTree.get_widget('labelCategoryOptions')
		textGeneralName.set_label('<b>'+_("options")+'</b>')

		textGeneralName = self.wTree.get_widget('checkRemoteUse')
		textGeneralName.set_active(config['remote']['use_remote'])
		textGeneralName.set_tooltip_text(_("synchronize to the remote server"))
		textGeneralName.connect("clicked", self.toggle_sensitive, "checkGeneralAutoshare")

		textGeneralName = self.wTree.get_widget('labelRemoteSleep')
		textGeneralName.set_label(_("time to wait for a synchronization (in seconds)"))

		textGeneralName = self.wTree.get_widget('spinRemoteSleep')
		textGeneralName.set_value(int(config['remote']['sleep']))
		textGeneralName.set_tooltip_text(_("interval in seconds in which a synchronization with the remote host occurs"))

		textGeneralName = self.wTree.get_widget('labelCategoryServerConf')
		textGeneralName.set_label('<b>'+_("server configuration")+'</b>')

		textGeneralName = self.wTree.get_widget('labelRemoteHostname')
		textGeneralName.set_label(_("hostname"))

		textGeneralName = self.wTree.get_widget('textRemoteHostname')
		textGeneralName.set_text(config['remote']['hostname'])
		textGeneralName.set_tooltip_text(_("the hostname of the remote server"))
		
		textGeneralName = self.wTree.get_widget('spinRemotePort')
		textGeneralName.set_value(int(config['remote']['port']))
		textGeneralName.set_tooltip_text(_("the port of the remote server"))

		textGeneralName = self.wTree.get_widget('labelRemoteUsername')
		textGeneralName.set_label(_("username"))
		textGeneralName.set_tooltip_text(_("the username for the remote server"))

		textGeneralName = self.wTree.get_widget('textRemoteUsername')
		textGeneralName.set_text(config['remote']['username'])
		textGeneralName.set_tooltip_text(_("the username for the remote server"))

		textGeneralName = self.wTree.get_widget('labelRemotePath')
		textGeneralName.set_label(_("repository path on the server"))

		textGeneralName = self.wTree.get_widget('textRemotePath')
		textGeneralName.set_text(config['remote']['path'])
		textGeneralName.set_tooltip_text(_("the path to the git repository on the remote server"))


		#remote actions
		textGeneralName = self.wTree.get_widget('labelCategoryActions')
		textGeneralName.set_label('<b>'+_("environment tests")+'</b>')

		textGeneralName = self.wTree.get_widget('labelTestsExplanation')
		textGeneralName.set_label(_("These are some tests to confirm if your settings are correct. If a problem occurs, the problem may be corrected if you run the corresponding action."))


		thewidget = self.wTree.get_widget("testLocalSSHKey")
		thewidget.connect("clicked", self.actionTestLocalSSHKey)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))

		thewidget = self.wTree.get_widget("testServerConnection")
		thewidget.connect("clicked", self.actionTestSSHAuth)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))


		thewidget = self.wTree.get_widget("testRemoteRepository")
		thewidget.connect("clicked", self.actionTestRemoteServer)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))


		thewidget = self.wTree.get_widget("buttonIsInSyncWithRemote")
		thewidget.connect("clicked", self.isInSyncWithRemote)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host'))

		textGeneralName = self.wTree.get_widget('labelRemoteRepository')
		textGeneralName.set_label(_("test status of remote repository"))

		thewidget = self.wTree.get_widget("buttonInitRemote")
		thewidget.connect("clicked", self.init_remote)
		thewidget.set_label(_("initialize"))
		thewidget.set_tooltip_text(_('run a initialization of the remote host'))

		textGeneralName = self.wTree.get_widget('labelSyncRemote')
		textGeneralName.set_label(_("is persy in a sync pack with remote host"))

		thewidget = self.wTree.get_widget("buttonSyncRemote")
		thewidget.connect("clicked", self.sync_with_remote)
		thewidget.set_label(_("link"))
		thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host'))



		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageLocalSSHKey')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageServerConnection')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageRemoteRepository')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageIsInSyncWithRemote')
		textGeneralName.set_from_pixbuf(pixbuf)


		#devel
		textGeneralName = self.wTree.get_widget('labelCategoryMonitoring')
		textGeneralName.set_label('<b>'+_("monitoring")+'</b>')

		textGeneralName = self.wTree.get_widget('labelGitBrowser')
		textGeneralName.set_label(_("start a git browser"))
		thewidget = self.wTree.get_widget("buttonBrowse")
		thewidget.connect("clicked", self.gtkcore.browse)
		thewidget.set_label(_("start"))
		thewidget.set_tooltip_text(_("starts %s")%config['general']['prefgitbrowser'])

		textGeneralName = self.wTree.get_widget('labelShowLog')
		textGeneralName.set_label(_("show log"))
		thewidget = self.wTree.get_widget("buttonLog")
		thewidget.connect("clicked", self.gtkcore.showlog)
		thewidget.set_label(_("show"))
		thewidget.set_tooltip_text(_('show log'))

		textGeneralName = self.wTree.get_widget('labelShowGitLog')
		textGeneralName.set_label(_("show git log"))

		thewidget = self.wTree.get_widget("buttonGitLog")
		thewidget.connect("clicked", self.gtkcore.showgitlog)
		thewidget.set_label(_("show"))
		thewidget.set_tooltip_text(_('show git log'))
Beispiel #4
0
class PersyGtkMenu():
	"""
	This class creates the settings menu.
	It uses glade to create the interface with the corresponding persy.glade file.
	"""
	def __init__(self, config, log, gtkcore):
	
		"""
		 *   builds the settings menu
		 *   does the localization of the gui
		 *   connects all buttons to the used actions
		"""

		#used do distinguish hboxes for watched entries
		self.hboxcounter = 0;

		self.config = config
		self.log = log
		self.gtkcore = gtkcore
		self.helper = PersyHelper()


		self.wTree = gtk.glade.XML(self.config.getAttribute('GLADEFILE'), 'window1')
		self.wTree.get_widget("window1").set_icon_from_file(self.config.getAttribute('LOGO'))
		self.wTree.get_widget("window1").set_title(_("persy settings"))

		self.wTree.get_widget("buttonSave").connect("clicked", self.save)
		self.wTree.get_widget("buttonSave").set_label(_("save"))


		textGeneralName = self.wTree.get_widget('labelGeneral')
		textGeneralName.set_label(_("general"))

		textGeneralName = self.wTree.get_widget('labelLocal')
		textGeneralName.set_label(_("backup"))

		textGeneralName = self.wTree.get_widget('labelRemote')
		textGeneralName.set_label(_("synchronization"))

		textGeneralName = self.wTree.get_widget('labelDevel')
		textGeneralName.set_label(_("administration"))

		#general configuration

		textGeneralName = self.wTree.get_widget('labelCategoryPersonal')
		textGeneralName.set_label('<b>'+_("personal information")+'</b>')

		textGeneralName = self.wTree.get_widget('labelGeneralName')
		textGeneralName.set_label(_("name"))

		textGeneralName = self.wTree.get_widget('textGeneralName')
		textGeneralName.set_text(config['general']['name'])
		textGeneralName.set_tooltip_text(_("username to distinguish different users for one share"))


		textGeneralName = self.wTree.get_widget('labelGeneralMail')
		textGeneralName.set_label(_("mail"))

		textGeneralName = self.wTree.get_widget('textGeneralMail')
		textGeneralName.set_text(config['general']['mail'])
		textGeneralName.set_tooltip_text(_("email to distinguish different users for one share"))

		textGeneralName = self.wTree.get_widget('labelCategoryAdvanced')
		textGeneralName.set_label('<b>'+_("advanced")+'</b>')

		a = autorun()
		textGeneralName = self.wTree.get_widget('checkGeneralAutostart')
		textGeneralName.set_active(a.exists('persy'))
		textGeneralName.set_label(_("start persy on login"))


		textGeneralName = self.wTree.get_widget('checkGeneralFortune')
		textGeneralName.set_active(config['general']['fortune'])
		textGeneralName.set_label(_("use fortune messages in the git commit"))
		
		if self.helper.which(config.getAttribute('FORTUNE')):
			textGeneralName.set_sensitive(True)
		else:
			textGeneralName.set_sensitive(False)
		
		textGeneralName = self.wTree.get_widget('checkGeneralAutoshare')
		textGeneralName.set_active(config['general']['autoshare'])
		textGeneralName.set_tooltip_text(_("if this is checked, all the computers in a sync will share the configuration file"))
		textGeneralName.set_label(_("share the configuration file") + _('(experimental)'))
		textGeneralName.set_sensitive(config['remote']['use_remote'])

		textGeneralName = self.wTree.get_widget('labelGeneralGitBrowser')
		textGeneralName.set_label(_("default git browser"))

		textGeneralName = self.wTree.get_widget('comboboxGeneralGitBrowser')

		for browser in self.config.getAttribute('GITGUI'):
			version = self.helper.getSoftwareVersion(browser)
			if version:
				textGeneralName.insert_text(0,browser)
				if self.config['general']['prefgitbrowser'] == browser:
					textGeneralName.set_active(0)
		textGeneralName.set_tooltip_text(_("the prefered git browser for browsing the local persy repository"))

		#local configuration
		textGeneralName = self.wTree.get_widget('labelLocalWatched')
		textGeneralName.set_label('<b>'+_("monitored folders in persy")+'</b>')

		for watched in config['local']['watched']:
			self.addWatchedEntry(None, watched)

		button = self.wTree.get_widget('buttonAddWatchedEntry')
		button.connect("clicked", self.addWatchedEntry, '')

		textGeneralName = self.wTree.get_widget('labelCategorySyncOptions')
		textGeneralName.set_label('<b>'+_("backup options")+'</b>')

		textGeneralName = self.wTree.get_widget('labelLocalSleep')
		textGeneralName.set_label(_("time to wait for a backup after an file action (in seconds)"))

		textGeneralName = self.wTree.get_widget('spinLocalSleep')
		textGeneralName.set_value(int(config['local']['sleep']))
		textGeneralName.set_tooltip_text(_("time to wait for a backup after an file action (in seconds)"))


		textGeneralName = self.wTree.get_widget('labelCategoryExclude')
		textGeneralName.set_label('<b>'+_("exclude options")+'</b>')

		textGeneralName = self.wTree.get_widget('labelLocalFilesize')
		textGeneralName.set_label(_("maximal allowed size of files (in bytes)"))

		textGeneralName = self.wTree.get_widget('spinLocalFilesize')
		textGeneralName.set_value(int(config['local']['maxfilesize']))
		textGeneralName.set_tooltip_text(_("all files larger than this value will be ignored"))


		textGeneralName = self.wTree.get_widget('labelLocalExclude')
		textGeneralName.set_label(_("exclude all files matching these regular expressions"))

		textGeneralName = self.wTree.get_widget('textLocalExclude')
		textGeneralName.set_text(", ".join(config['local']['exclude']))
		textGeneralName.set_tooltip_text(_("the expressions are seperated by a comma"))

		textGeneralName = self.wTree.get_widget('labelCategoryExclude1')
		textGeneralName.set_label('<b>'+_("excluded submodules / directories")+'</b>')

		textGeneralName = self.wTree.get_widget('label1')
		textGeneralName.set_text(_("these directories are git submodules and can not be tracked with persy")+':')


		textGeneralName = self.wTree.get_widget('label2')
		submodules = self.gtkcore.get_submodules()
		if submodules:
			textGeneralName.set_text("\n".join(submodules))
		else:
			textGeneralName.set_text("none!")

		#remote configuration
		textGeneralName = self.wTree.get_widget('labelCategoryOptions')
		textGeneralName.set_label('<b>'+_("options")+'</b>')

		textGeneralName = self.wTree.get_widget('checkRemoteUse')
		textGeneralName.set_active(config['remote']['use_remote'])
		textGeneralName.set_tooltip_text(_("synchronize to the remote server"))
		textGeneralName.connect("clicked", self.toggle_sensitive, "checkGeneralAutoshare")

		textGeneralName = self.wTree.get_widget('labelRemoteSleep')
		textGeneralName.set_label(_("time to wait for a synchronization (in seconds)"))

		textGeneralName = self.wTree.get_widget('spinRemoteSleep')
		textGeneralName.set_value(int(config['remote']['sleep']))
		textGeneralName.set_tooltip_text(_("interval in seconds in which a synchronization with the remote host occurs"))

		textGeneralName = self.wTree.get_widget('labelCategoryServerConf')
		textGeneralName.set_label('<b>'+_("server configuration")+'</b>')

		textGeneralName = self.wTree.get_widget('labelRemoteHostname')
		textGeneralName.set_label(_("hostname"))

		textGeneralName = self.wTree.get_widget('textRemoteHostname')
		textGeneralName.set_text(config['remote']['hostname'])
		textGeneralName.set_tooltip_text(_("the hostname of the remote server"))
		
		textGeneralName = self.wTree.get_widget('spinRemotePort')
		textGeneralName.set_value(int(config['remote']['port']))
		textGeneralName.set_tooltip_text(_("the port of the remote server"))

		textGeneralName = self.wTree.get_widget('labelRemoteUsername')
		textGeneralName.set_label(_("username"))
		textGeneralName.set_tooltip_text(_("the username for the remote server"))

		textGeneralName = self.wTree.get_widget('textRemoteUsername')
		textGeneralName.set_text(config['remote']['username'])
		textGeneralName.set_tooltip_text(_("the username for the remote server"))

		textGeneralName = self.wTree.get_widget('labelRemotePath')
		textGeneralName.set_label(_("repository path on the server"))

		textGeneralName = self.wTree.get_widget('textRemotePath')
		textGeneralName.set_text(config['remote']['path'])
		textGeneralName.set_tooltip_text(_("the path to the git repository on the remote server"))


		#remote actions
		textGeneralName = self.wTree.get_widget('labelCategoryActions')
		textGeneralName.set_label('<b>'+_("environment tests")+'</b>')

		textGeneralName = self.wTree.get_widget('labelTestsExplanation')
		textGeneralName.set_label(_("These are some tests to confirm if your settings are correct. If a problem occurs, the problem may be corrected if you run the corresponding action."))


		thewidget = self.wTree.get_widget("testLocalSSHKey")
		thewidget.connect("clicked", self.actionTestLocalSSHKey)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))

		thewidget = self.wTree.get_widget("testServerConnection")
		thewidget.connect("clicked", self.actionTestSSHAuth)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))


		thewidget = self.wTree.get_widget("testRemoteRepository")
		thewidget.connect("clicked", self.actionTestRemoteServer)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('show git log'))


		thewidget = self.wTree.get_widget("buttonIsInSyncWithRemote")
		thewidget.connect("clicked", self.isInSyncWithRemote)
		thewidget.set_label(_("test"))
		thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host'))

		textGeneralName = self.wTree.get_widget('labelRemoteRepository')
		textGeneralName.set_label(_("test status of remote repository"))

		thewidget = self.wTree.get_widget("buttonInitRemote")
		thewidget.connect("clicked", self.init_remote)
		thewidget.set_label(_("initialize"))
		thewidget.set_tooltip_text(_('run a initialization of the remote host'))

		textGeneralName = self.wTree.get_widget('labelSyncRemote')
		textGeneralName.set_label(_("is persy in a sync pack with remote host"))

		thewidget = self.wTree.get_widget("buttonSyncRemote")
		thewidget.connect("clicked", self.sync_with_remote)
		thewidget.set_label(_("link"))
		thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host'))



		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageLocalSSHKey')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageServerConnection')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageRemoteRepository')
		textGeneralName.set_from_pixbuf(pixbuf)

		pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24)
		textGeneralName = self.wTree.get_widget('imageIsInSyncWithRemote')
		textGeneralName.set_from_pixbuf(pixbuf)


		#devel
		textGeneralName = self.wTree.get_widget('labelCategoryMonitoring')
		textGeneralName.set_label('<b>'+_("monitoring")+'</b>')

		textGeneralName = self.wTree.get_widget('labelGitBrowser')
		textGeneralName.set_label(_("start a git browser"))
		thewidget = self.wTree.get_widget("buttonBrowse")
		thewidget.connect("clicked", self.gtkcore.browse)
		thewidget.set_label(_("start"))
		thewidget.set_tooltip_text(_("starts %s")%config['general']['prefgitbrowser'])

		textGeneralName = self.wTree.get_widget('labelShowLog')
		textGeneralName.set_label(_("show log"))
		thewidget = self.wTree.get_widget("buttonLog")
		thewidget.connect("clicked", self.gtkcore.showlog)
		thewidget.set_label(_("show"))
		thewidget.set_tooltip_text(_('show log'))

		textGeneralName = self.wTree.get_widget('labelShowGitLog')
		textGeneralName.set_label(_("show git log"))

		thewidget = self.wTree.get_widget("buttonGitLog")
		thewidget.connect("clicked", self.gtkcore.showgitlog)
		thewidget.set_label(_("show"))
		thewidget.set_tooltip_text(_('show git log'))


	def save(self, widget, data=None):
		"""
		converts the values from the gui to PersyConfig values and executes the save function on the config object
		"""
		self.log.info("saving configuration")
		#general configuration
		textGeneralName = self.wTree.get_widget('textGeneralName')
		self.config['general']['name'] = textGeneralName.get_text()

		textGeneralName = self.wTree.get_widget('textGeneralMail')
		self.config['general']['mail'] = textGeneralName.get_text()

		textGeneralName = self.wTree.get_widget('checkGeneralFortune')
		self.config['general']['fortune'] = textGeneralName.get_active()

		textGeneralName = self.wTree.get_widget('checkGeneralAutostart')
		autostart = textGeneralName.get_active()
		a = autorun()
		if autostart and not a.exists('persy'):
			a.add('persy', self.config.getAttribute('PERSY_BIN') + ' --start')
		if not autostart and a.exists('persy'):
			a.remove('persy')


		textGeneralName = self.wTree.get_widget('comboboxGeneralGitBrowser')
		self.config['general']['prefgitbrowser'] = textGeneralName.get_active_text()

		#local configuration
		textGeneralName = self.wTree.get_widget('spinLocalSleep')
		self.config['local']['sleep'] = int(textGeneralName.get_value())


		root = self.wTree.get_widget('vbox4')
		tmparray = []
		for entry in root:
			for child in entry:
				if child.get_name().startswith('text_'):
					tmparray.append(child.get_text())
		self.config['local']['watched'] = tmparray


		
		textGeneralName = self.wTree.get_widget('spinLocalFilesize')
		self.config['local']['maxfilesize'] = int(textGeneralName.get_value())

		textGeneralName = self.wTree.get_widget('textLocalExclude')
		self.config['local']['exclude'] = self.helper.striplist(textGeneralName.get_text().split(','))

		#remote configuration
		textGeneralName = self.wTree.get_widget('checkRemoteUse')
		self.config['remote']['use_remote'] = textGeneralName.get_active()


		textGeneralName = self.wTree.get_widget('spinRemoteSleep')
		self.config['remote']['sleep'] = int(textGeneralName.get_value())
		#textGeneralName.set_value(-1)

		textGeneralName = self.wTree.get_widget('textRemoteHostname')
		self.config['remote']['hostname'] = textGeneralName.get_text()
		
		textGeneralName = self.wTree.get_widget('spinRemotePort')
		self.config['remote']['port'] = int(textGeneralName.get_value())		

		textGeneralName = self.wTree.get_widget('textRemotePath')
		self.config['remote']['path'] = textGeneralName.get_text()

		textGeneralName = self.wTree.get_widget('textRemoteUsername')
		self.config['remote']['username'] = textGeneralName.get_text()

		textGeneralName = self.wTree.get_widget('checkGeneralAutoshare')
		self.config['general']['autoshare'] = textGeneralName.get_active()

		#write the configuration
		self.config.write()

		#set the sensitivity of the sync now button in the menu
		self.gtkcore.check_syncnow()

	def addWatchedEntry(self, widget, watched):
		"""
		code for adding a new entry for a watched directory to the gui
		"""
		root = self.wTree.get_widget('vbox4')

		hbox = gtk.HBox()
		hbox.set_name("hbox_%i"%self.hboxcounter)
		
		textLabel = gtk.Entry()
		textLabel.set_text(watched)
		textLabel.set_name("text_"+watched)
		textLabel.show()
		hbox.add(textLabel)


		button = gtk.Button('choose')
		button.connect("clicked", self.launchFileChooser, watched)
		button.set_label(_('choose'))
		button.show()
		hbox.pack_start(button, False, False)
		#hbox.add(button)

		
		button = gtk.Button('-')
		button.connect("clicked", self.removeWatchedEntry, self.hboxcounter)
		button.set_label(_(' - '))
		button.show()
		hbox.pack_start(button, False, False)
		#hbox.add(button)
		
		hbox.show()
		root.add(hbox)
		self.hboxcounter += 1


	def removeWatchedEntry(self, widget, data = None):
		"""
		removing a watched directory entry from the widget. 
		the name of the directory is stored in data
		"""
		for child in widget.get_parent().get_parent().get_children():
			if child.get_name() == "hbox_%i"%data:
				child.destroy()
		
		#resize the window to the minimal size
		self.wTree.get_widget("window1").resize(1, 1)


	def launchFileChooser(self, widget, data = None):
		"""
		launchdes a filechooser dialog for a folder
		"""
		filechooser =  gtk.FileChooserDialog(title=None	,action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
		response = filechooser.run()
		try:
			if response == gtk.RESPONSE_OK:
				filename = filechooser.get_filename()
				#remove the userhome from the path
				if filename.startswith(self.config.getAttribute('USERHOME')):
					filename = filename[len(self.config.getAttribute('USERHOME'))+1:]
			
				for child in widget.get_parent().get_children():
					if child.get_name() == 'text_'+data:
						child.set_text(filename)
		except Exception as e:
			pass
		finally:
			filechooser.destroy()
			


	def actionTestRemoteServer(self, widget, data= None):
		"""
		persy environment test action.
		uses PersySSH to check the remote Server
		"""
		persyssh = PersySSH(self.config, self.log)
		if persyssh.checkRemoteServer():
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_OK'), 24, 24)
			thewidget = self.wTree.get_widget('imageRemoteRepository')
			thewidget.set_tooltip_text(_('all ok'))
		else:
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_ERROR'), 24, 24)
			thewidget = self.wTree.get_widget('imageRemoteRepository')
			thewidget.set_tooltip_text(_('the remote repository is not ok. maybe the path on the server is incorrect or it is not initialized. run the "initialize" action to do so'))

		textGeneralName = self.wTree.get_widget('imageRemoteRepository')
		textGeneralName.set_from_pixbuf(pixbuf)

	def actionTestSSHAuth(self, widget, data= None):
		"""
		persy environment test action.
		uses PersySSH to check the server authentification
		"""
		persyssh = PersySSH(self.config, self.log)
		if persyssh.checkSSHAuth():
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_OK'), 24, 24)
			thewidget = self.wTree.get_widget('imageServerConnection')
			thewidget.set_tooltip_text(_('all ok'))
		else:
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_ERROR'), 24, 24)
			thewidget = self.wTree.get_widget('imageServerConnection')
			thewidget.set_tooltip_text(_('the connection to the server was not possible. please check your settings above and if you have published your ssh public key to the server. if not, you can run the "publish" action'))

		textGeneralName = self.wTree.get_widget('imageServerConnection')
		textGeneralName.set_from_pixbuf(pixbuf)

	def actionTestLocalSSHKey(self, widget, data= None):
		"""
		persy environment test action.
		uses PersySSH to check if local ssh keys do exist
		"""
		persyssh = PersySSH(self.config, self.log)
		if persyssh.localSSHKeysExist():
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_OK'), 24, 24)
			thewidget = self.wTree.get_widget('imageLocalSSHKey')
			thewidget.set_tooltip_text(_('all ok'))
		else:
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_ERROR'), 24, 24)
			thewidget = self.wTree.get_widget('imageLocalSSHKey')
			thewidget.set_tooltip_text(_('no local ssh keys are present. these are important for a serverconnection. you may want to run the "create" action to create these'))

		textGeneralName = self.wTree.get_widget('imageLocalSSHKey')
		textGeneralName.set_from_pixbuf(pixbuf)

	def isInSyncWithRemote(self, widget, data= None):
		"""
		persy environment test action.
		uses gtkcore to test if persy is in sync with remote (has an git-remote entry for origin)
		"""
		if self.gtkcore.isInSyncWithRemote(widget):
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_OK'), 24, 24)
			thewidget = self.wTree.get_widget('imageIsInSyncWithRemote')
			thewidget.set_tooltip_text(_('all ok'))
		else:
			pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_ERROR'), 24, 24)
			thewidget = self.wTree.get_widget('imageIsInSyncWithRemote')
			thewidget.set_tooltip_text(_('persy is not in sync with the remote server. you may want to run the "link" action to fix this'))

		textGeneralName = self.wTree.get_widget('imageIsInSyncWithRemote')
		textGeneralName.set_from_pixbuf(pixbuf)
		
	
	def toggle_sensitive(self, widget, data=None):
		"""
		changes sensitive from widgets
		"""
		self.wTree.get_widget(data).set_sensitive(widget.get_active())

	def sync_with_remote(self, widget, data=None):
		dia = gtk.Dialog(_('Question!'),
				 widget.get_toplevel(),  #the toplevel wgt of your app
				 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,  #binary flags or'ed together
				 (_("synchronize now"), 77, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
		label = gtk.Label(_('Do you want to synchronize now? This should only be done once at the beginning.'))
		label.show()
		dia.vbox.pack_start(label)
		dia.show()
		result = dia.run()
		if result == 77:
			self.gtkcore.syncWithRemote()
		dia.destroy()

	def init_remote(self, widget, data=None):
		dia = gtk.Dialog(_('Question!'),
				 widget.get_toplevel(),  #the toplevel wgt of your app
				 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,  #binary flags or'ed together
				 (_("initialize now"), 77, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
		label = gtk.Label(_('Do you want to initialize now? This should only be done once at the beginning.'))
		label.show()
		dia.vbox.pack_start(label)
		dia.show()
		result = dia.run()
		if result == 77:
			self.gtkcore.initRemote(widget, data)
		dia.destroy()
Beispiel #5
0
def main(argv):
	"""
	the main function. the command line arguments are processed here and the next actions are started here too
	"""
	args = argv[1:]

	#cli options
	from optparse import OptionParser
	parser = OptionParser(usage = _("use --start to start the daemon"))
	parser.add_option("--start", action="store_true", default=False, help=_("starts persy"))
	parser.add_option("--initremote", action="store_true", default=False, help=_("initializes the remote repository"))
	parser.add_option("--syncwithremote", action="store_true", default=False, help=_("syncs with a remote repository"))
	parser.add_option("--browse", action="store_true", default=False, help=_("start a git browser"))
	parser.add_option("--log", action="store_true", default=False, help=_("prints git log"))
	parser.add_option("--status", action="store_true", default=False, help=_("prints git status"))
	parser.add_option("--ignore", action="store_true", default=False, help=_("recreates list of all ignored files"))
	parser.add_option("--verbose", action="store_true", default=False, help=_("print git output to stdout and set loglevel to DEBUG"))
	parser.add_option("--actions", action="store_true", default=False, help=_("list of computer-readable actions in persy"))
	parser.add_option("--optimize", action="store_true", default=False, help=_("optimizes the stored files. saves space and improves performance"))
	parser.add_option("--configfile", dest="configfile", default=None, help=_("use a non-default config file"))
	parser.add_option("--config", action="store_true", default=False, help=_("needed flag to change configurations"))
	parser.add_option("--version", action="store_true", default=False, help=_("prints the version"))
	parser.add_option("--uname", dest="uname", default="", help=_("username used in commit"))
	parser.add_option("--mail", dest="mail", default="", help=_("useremail used in commit"))
	parser.add_option("--headless", action="store_true", default=False, help=_("run in headless(no gui) mode"))
	parser.add_option("--path", dest="path", default="", help=_("path on the server"))
	parser.add_option("--hostname", dest="hostname", default="", help=_("hostname of the remote server"))
	parser.add_option("--add_dir", dest="add_dir", default="", help=_("add local wachted folders"))
	(options, args) = parser.parse_args(args)

	#creat the configuration
	config =  PersyConfig(options.configfile)

	#change in the userhome for all actions
	os.chdir(config.getAttribute('USERHOME'))

	#create programdirectory and a default config file
	if not os.path.exists(config.getAttribute('PERSY_DIR')):
		os.makedirs(config.getAttribute('PERSY_DIR'))

	log = Talker(config, options.verbose) #verbose = print ALL output to stdout
	log.setLevel(options.verbose) #true = debug, false = info set verbosity to show all messages of severity >= DEBUG

	if options.config:
		changed = False
		if options.hostname:
			changed = True
			config['remote']['hostname'] = options.hostname
		if options.path:
			changed = True
			config['remote']['path'] = options.path
		if options.uname:
			changed = True
			config['general']['name'] = options.uname
		if options.mail:
			changed = True
			config['general']['mail'] = options.mail
		if options.add_dir:
			changed = True
			if type(config['local']['watched']) is str:
				if config['local']['watched']:
					config['local']['watched'] = [config['local']['watched'], options.add_dir]
				else:
					config['local']['watched'] = [options.add_dir]
			else:
				config['local']['watched'].append(options.add_dir)
		if changed:
			config.write()
			log.info("writing new config")
		else:
			log.warn(_("nothing changed, maybe wrong attribute names?"))
		sys.exit(0)
	elif options.syncwithremote or options.initremote:
		if options.hostname:
			config['remote']['hostname'] = options.hostname
		if options.path:
			config['remote']['path'] = options.path
		config['remote']['use_remote'] = True
		config.write()


	core = Core()
	core.init(config, log)


	#check if a local repository is initialized:
	if not core.isLocalInitialized():
		core.init_local()

	if options.initremote:
		core.initRemote()
	elif options.version:
		persyhelper = PersyHelper()
		print persyhelper.getSoftwareVersion('persy')
	elif options.syncwithremote:
		core.syncWithRemote()
	elif options.browse:
		core.browse()
	elif options.log:
		core.vcslog()
	elif options.status:
		core.vcsstatus()
	elif options.ignore:
		core.vcsignore()
	elif options.optimize:
		core.optimize()
	elif options.actions:
		#this i used for cli completion
		for opt in parser.option_list:
			print opt.get_opt_string(),
		sys.exit(0)
	else:
		#check if all the icons are present, just warn is something is missing
		filestocheck = (config.getAttribute('ICON_IDLE'), config.getAttribute('ICON_OK'),
			config.getAttribute('ICON_UNSYNCED'), config.getAttribute('ICON_UNTRACKED'),
			config.getAttribute('ICON_WARN'), config.getAttribute('ICON_ERROR'), 
			config.getAttribute('LOGO'))
		fileresults = map(os.path.exists, filestocheck)
		i = 0 
		for fileresult in fileresults:
			if not fileresult:
				log.warn(_("%s file is missing!") % filestocheck[i])
			i += 1


		#START!
		if options.headless:
			core.persy_start()
		else:
			pgtk = PersyGtk()
			pgtk.init(core, config, log, options.start)