gbacker-svn Mailing List for gbacker
Status: Beta
Brought to you by:
stas_zytkiewicz
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(20) |
|---|
|
From: <sta...@us...> - 2009-12-27 09:06:25
|
Revision: 13
http://gbacker.svn.sourceforge.net/gbacker/?rev=13&view=rev
Author: stas_zytkiewicz
Date: 2009-12-27 09:06:17 +0000 (Sun, 27 Dec 2009)
Log Message:
-----------
foo
Modified Paths:
--------------
Constants.py
Modified: Constants.py
===================================================================
--- Constants.py 2009-12-27 08:53:59 UTC (rev 12)
+++ Constants.py 2009-12-27 09:06:17 UTC (rev 13)
@@ -1,4 +1,4 @@
-# Constants used by gbacker
+# Constants used by gbacker
import os
import sys
# Packagers, make sure to change the IBSIGRCPATH to the directory path
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-27 09:06:23
|
Revision: 13
http://gbacker.svn.sourceforge.net/gbacker/?rev=13&view=rev
Author: stas_zytkiewicz
Date: 2009-12-27 09:06:17 +0000 (Sun, 27 Dec 2009)
Log Message:
-----------
foo
Modified Paths:
--------------
Constants.py
Modified: Constants.py
===================================================================
--- Constants.py 2009-12-27 08:53:59 UTC (rev 12)
+++ Constants.py 2009-12-27 09:06:17 UTC (rev 13)
@@ -1,4 +1,4 @@
-# Constants used by gbacker
+# Constants used by gbacker
import os
import sys
# Packagers, make sure to change the IBSIGRCPATH to the directory path
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-27 08:54:09
|
Revision: 12
http://gbacker.svn.sourceforge.net/gbacker/?rev=12&view=rev
Author: stas_zytkiewicz
Date: 2009-12-27 08:53:59 +0000 (Sun, 27 Dec 2009)
Log Message:
-----------
Major updates
Modified Paths:
--------------
GuiGtk.py
Optparser.py
Worker.py
gbacker.py
gimap.py
glade/gui.ui
utils.py
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 09:56:19 UTC (rev 11)
+++ GuiGtk.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -74,6 +74,7 @@
self.parent = parent
glade_path = os.path.join(GLADEDIR, glade_path)
SimpleGladeApp.__init__(self, glade_path, root, domain)
+ self.current_frame = self.start_frame
# get our imap related stuff
self.ac = ImapAccount(options)
# Start a splash like dialog because the building of the empty tree can
@@ -108,7 +109,7 @@
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
self.remote_tree_widget = None
- self.window1.show_all()
+ self.window1.show()
# setup our threaded progressbar
self.pbar = gtk.ProgressBar()
self.pbar.set_pulse_step(0.1)
@@ -124,6 +125,33 @@
####### menu callbacks ##########
# Quit from the menu is connected to the on_window1_delete_event
+ def on_welcome_screen_activate(self, widget, *args):
+ self.logger.debug('on_welcome_screen_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_account_settings_activate(self, widget, *args):
+ self.logger.debug('on_account_settings_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_delete_dir_activate(self, widget, *args):
+ self.logger.debug('on_delete_dir_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_sync_remote_activate(self, widget, *args):
+ self.logger.debug('on_sync_remote_activate called with self.%s' % widget.get_name())
+ self.current_frame.hide()
+ self.sync_remote_frame.show()
+ self.current_frame = self.sync_remote_frame
+ return True
+
+ def on_upload_dir_activate(self, widget, *args):
+ self.logger.debug('on_upload_dir_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_download_dir_activate(self, widget, *args):
+ self.logger.debug('on_download_dir_activate called with self.%s' % widget.get_name())
+ return True
+
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
@@ -193,7 +221,7 @@
if self.remote_tree_widget:
self.remote_tree_widget.view.hide()
return True
-
+ ########### button callbacks filebrowser ##############
def on_button_arrow_right_clicked(self, widget, *args):
# upload selection
self.logger.debug('on_button_arrow_right_clicked called with self.%s' % widget.get_name())
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-13 09:56:19 UTC (rev 11)
+++ Optparser.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -51,7 +51,7 @@
help="Full path of the remote directory to download. Use the option -d to give a target destination for the download",
dest="restore")
self.add_option("-b", "--backup",
- help="Fuul path of the directory to backup.",
+ help="Full path of the directory to backup.",
dest="backup")
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
@@ -59,7 +59,12 @@
self.add_option("--rebuilddb",action="store_true",
help="Rebuilds the database in case it's corrupted. It will download all the subject lines from the Gmail messages in the account to rebuild the database table. Corruption of the database occurs when the program would crash or when you have a very flaky network connection.",
dest="rebuilddb")
-
+ self.add_option("-y", "--sync_remote",
+ help="Bring the remote directory, 'SYNC_REMOTE', in sync with the local directory. This will upload missing files and delete remote files that no longer available locally. Use this with care. If you sync a empty local directory all the remote files will be deleted.",
+ dest="sync_remote")
+ self.add_option("", "--delete_directory",
+ help="Full path of the remote directory, 'DELETE_DIRECTORY', to delete. This will completely remove the remote files and this deletion can not be reverted.",
+ dest="delete_directory")
(self.options, self.args) = self.parse_args()
def exit(self,*args):
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-13 09:56:19 UTC (rev 11)
+++ Worker.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -29,6 +29,7 @@
from gimap import ComposedMessage, Sender, ServerError, NoLoginError
from Constants import *
+from utils import parse_body
class ReadError(Exception):
pass
@@ -70,21 +71,10 @@
lines and values, the file path and the attachment.
the attachment is the raw file contants."""
payload = msg.get_payload()
- bodydict, path = self._parse_body(payload[1].as_string())
+ bodydict, path = parse_body(payload[1].as_string())
attachment = payload[0].get_payload(decode=True)
return bodydict, path, attachment
- def _parse_body(self, text):
- dict = {}
- items = MESSAGEBODYITEMS
-
- for line in text.split('\n'):
- for k in items:
- if k in line:
- dict[k.replace(':', '', 1).strip()] = line.split(':', 1)[1].strip()
- path = dict['path']
- return dict, path
-
class Uploader:
"""Sends a message and verifies that it is received properly by the server.
The message must be constructed by the Packager.
@@ -141,7 +131,18 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id and not self.sync:
+ if mesg_id and self.sync:
+ self.logger.debug("Found remote message: %s, checking if it differs" % mesg_id)
+ path, body= self.ac.fetch_body(mesg_id).items()[0]
+ remote_dict, path = parse_body('\n'.join(body))
+ local_dict, path = parse_body(msg.get_body())
+ if local_dict['creation'] == remote_dict['creation'] and \
+ local_dict['size'] == remote_dict['size']:
+ self.logger.debug("Files are the same, stopping the upload")
+ return ['OK', 'Files are the same, local file not send']
+ else:
+ self.logger.debug("Files differ, continuing the upload")
+ if mesg_id:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -163,10 +164,6 @@
self.logger.debug("Trashed message(s) with mesg_id(s): %s" % mesg_id)
# update dbase and empty tree
self.db.remove_message(mesg_subject_list)
- elif mesg_id and self.sync:
- self.logger.debug("Found remote message: %s, leaving it alone" % mesg_id)
- # TODO: check creationtime and size to determine if the file isn't changed
- return
else:
self.logger.debug("No old message found")
# DB will change the subject line by adding a table id, for example 'ID8'
@@ -178,14 +175,19 @@
maxtries = 3
tries = 0
while tries < maxtries :
- result = self.sender.send_message(new_msg)
+ try:
+ result = self.sender.send_message(new_msg)
+ except Exception, e:
+ self.logger.critical("Uncatched exception catched, error in the Sender class")
+ result = ('Fail', ' ')
if result[0] != 'OK':
self.logger.error("Failed to send the message, check the logs: %s" % result)
- tries += 1
self.logger.warning("Will try to send the message again, attempt %s" % tries)
tries += 1
self.logger.debug("reconnecting to server")
self.ac.logout()
+ self.logger.debug("Logged out, waiting 5 seconds before attempting to login again.")
+ time.sleep(5)
try:
self.ac.login_ssl()
except NoLoginError, e:
@@ -435,7 +437,7 @@
for k, v in subdict.items():
self.logger.debug("subject: %s" % k)
self.logger.debug("body:%s" % bodydict[k])
- d = packager._parse_body('\n'.join(bodydict[k]))[0]
+ d = parse_body('\n'.join(bodydict[k]))[0]
try:
self.ce(''' INSERT INTO messages VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
@@ -476,7 +478,7 @@
self.logger.debug("upload_new_message called with:%s" % mesg)
# unpack the mesg
p = Packager()
- d, path = p._parse_body(mesg.get_body())
+ d, path = parse_body(mesg.get_body())
self.ce(''' INSERT INTO messages VALUES
( NULL, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
(self.account, d['path'], d['current_dir'], d['creation'], d['up_load'],\
@@ -652,7 +654,7 @@
# TODO: implement tags
tag = ''
info = ("path: %s" % filename,\
- "creation: %s" % time.ctime(statinfo.st_mtime),\
+ "creation: %s" % statinfo.st_mtime,\
"size: %s" % str(max(1, statinfo.st_size/1024))+' KB',\
"up_load: %s" % time.asctime(), \
"encrypt: %s" % encrypt,\
@@ -844,7 +846,7 @@
else:
return True
- def upload_directory(self, directory, hidden=False):
+ def upload_directory(self, directory, hidden=False, sync=False):
"""Uploads the complete directory to the Gmail Drafts folder.
The packager will create a email.Message object with the proper subject line.
It then passes the message to the uploader which will append it to the drafts folder
@@ -855,8 +857,9 @@
The dbase update is done by uploader.
Returns True on success and None on failure.
"""
+ #TODO: implement @hidden
self.logger.debug("Start uploading %s" % directory)
- self.uploader = Uploader(self.ac, self.db, self.treebuilder)
+ self.uploader = Uploader(self.ac, self.db, self.treebuilder, sync)
self.packager = Packager()
self.directoryreader = DirectoryReader(directory)
@@ -903,7 +906,7 @@
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails.
"""
- # strip the emptytree part form the path
+ # strip the emptytree part form the path in case we are called from the GUI
directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for %s##" % directory)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT %s##)' % directory)
@@ -956,11 +959,11 @@
When there's no difference None is returned.
"""
# first get a list with remote filenames form the empty tree
-
remotefilelist = self.treebuilder.get_dir_contents(directory)
+ # then one from the local tree
self.directoryreader = DirectoryReader(directory)
localfilelist = self.directoryreader.get_filenames_from_dir()
-
+ # diff them
s = set(localfilelist)
locallist = []
for i in s.difference(remotefilelist):
@@ -979,6 +982,16 @@
available locally.
Use this with care. If you sync a empty local directory all the remote
files will be deleted."""
+ # first we get a diff list
+ difflist = self.diff(directory)
+ self.logger.debug("Found difference list: %s" % difflist)
+ # here we remove all the paths that are only in remote.
+ for place, path in difflist:
+ if place == 'remote':
+ self.delete_remote_file(path)
+ # the only local files will be handled by the uploader as well as the
+ # changed local files.
+ self.upload_directory(directory, sync=True)
def sync_local(self, directory, dest):
"""Update a local directory with the remote directory.
@@ -1019,13 +1032,13 @@
w = Worker(ac)
#w.rebuild_dbase()
#w.upload_directory('/home/stas/temp/test_pics')
- #w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
+ #w.upload_directory('/home/stas/temp/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
# print k, v
- #w.download_directory('/home/stas/SVN-WORK/gbacker/TestDir', '/tmp')
- #w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
+ #w.download_directory('/home/stas/temp/TestDir', '/tmp')
+ #w.download_file('/home/stas/temp/TestDir/test1.txt', '/tmp')
#w.build_remote_tree()
#w.delete_remote_dir(os.path.abspath('TestDir'))
@@ -1034,9 +1047,12 @@
# for i in w.diff(os.path.abspath('TestDir')):
# print i
-# rr = RemoteDirectoryReader(ac, '/home/stas/SVN-WORK/gbacker')
+# rr = RemoteDirectoryReader(ac, '/home/stas/temp')
# files = rr.get_filenames_from_dir()
# print files
+
+ w.sync_remote('/home/stas/temp/TestDir')
+
raw_input("hit any key to stop")
w.stop()
ac.logout()
Modified: gbacker.py
===================================================================
--- gbacker.py 2009-12-13 09:56:19 UTC (rev 11)
+++ gbacker.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -51,7 +51,8 @@
# When the options backup or restore are given we don't start the gui but
# start Worker our selfs.
-if CMD_Options.backup or CMD_Options.restore:
+if CMD_Options.backup or CMD_Options.restore or CMD_Options.sync_remote or\
+ CMD_Options.delete_directory:
from gimap import ImapAccount
from Worker import Worker
ac = ImapAccount()
@@ -61,6 +62,10 @@
w.upload_directory(CMD_Options.backup)
elif CMD_Options.restore:
w.download_directory(CMD_Options.restore, CMD_Options.destination)
+ elif CMD_Options.sync_remote:
+ w.sync_remote(CMD_Options.sync_remote)
+ elif CMD_Options.delete_directory:
+ w.delete_remote_dir(CMD_Options.delete_directory)
elif CMD_Options.rebuilddb:
from gimap import ImapAccount
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-13 09:56:19 UTC (rev 11)
+++ gimap.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -21,7 +21,7 @@
import socket
socket.setdefaulttimeout(10)
-
+from ssl import SSLError
import imaplib
import time
import sys
@@ -102,7 +102,8 @@
"""atexit func to make sure we always do a proper gmail logout"""
try:
if self.AC:
- self.logout()
+ self.AC.close()
+ self.AC.logout()
except Exception, e:
self.logger.debug("_panic_logout raises and exception: %s" % e)
@@ -207,7 +208,7 @@
self.logger.debug("logout called")
if self.AC:
try:
- #self.AC.close()
+ self.AC.close()
self.AC.logout()
except Exception, e:
self.logger.error("Error while closing connection: %s" % e)
@@ -511,61 +512,6 @@
raise ServerError,"Error parsing getquota string, Gmail probably changed the getquotaroot response."
return data
- ####### various abstraction methods to mimic a real filesystem
-# def os_path_isdir(self, path):
-# """os.path.isdir replacement for testing a remote dir."""
-# ids = self.get_id('[Gmail]/All Mail','(SUBJECT "%s##")' % path)
-# if ids:
-# for mesg_id in ids.split(','):
-# try:
-# data = self.fetch_subject(mesg_id)
-# except ServerError, e:
-# self.logger.error("Failed to download the subject header from message with mesg_id: %s, %s" % (mesg_id, e))
-# raise ReadError
-# else:
-# dirname, fname = data[0][1].split('##')
-# dirname = dirname.split('Subject:')[1].strip()
-# if dirname == path:
-# return True
-# else:
-# return False
-# return False
-#
-## def os_path_join(self, *files):
-## """os.path.join replacement for handling paths returnt by a gimap method ."""
-## pass
-#
-# def os_listdir(self, dir):
-# """os.listdir replacement for list the contents of a remote directory."""
-# self.logger.debug("Getting contents of remote directory: %s" % dir)
-# try:
-# ids = self.get_id('[Gmail]/All Mail','(SUBJECT "%s##")' % dir)
-# except ServerError, e:
-# self.logger.error("Failed to get ids: %s" % e)
-# if not ids:
-# return []
-# filelist = []
-# buckets = {}
-# for mesg_id in ids.split(','):
-# try:
-# data = self.fetch_subject(mesg_id)
-# except ServerError, e:
-# self.logger.error("Failed to download the subject header from message with mesg_id: %s, %s" % (mesg_id, e))
-# raise ReadError
-# else:
-# dirname, fname = data[0][1].split('##')
-# dirname = dirname.split('Subject:')[1].strip()
-# fname = fname.strip()
-# # don't include contents of sub dirs
-# if dir == dirname:
-# # fname is part of dir
-# filelist.append(fname)
-# elif '/' in dirname.replace(dir, '', 1):
-# # dirname is a subdirectory
-# buckets[dirname] = None
-# filelist += buckets.keys()
-# return filelist
-
class Sender:
"""Object which uploads a message to the Gmail imap server and appends it to the Drafts folder."""
def __init__(self, server, imap_user, imap_pass):
@@ -585,7 +531,7 @@
emailmesg = mesg.get_message()
try:
result = self.server.append(draftsbox, '', '', emailmesg.as_string())
- except self.server.abort, e:
+ except (self.server.abort, SSLError), e:
self.logger.error("failed to append message: %s" % e)
result = ['Timeout', str(e)]
if result[0] != 'OK':
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 09:56:19 UTC (rev 11)
+++ glade/gui.ui 2009-12-27 08:53:59 UTC (rev 12)
@@ -23,6 +23,53 @@
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
+ <object class="GtkMenuItem" id="imagemenuitem1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Welcome screen</property>
+ <signal name="activate" handler="on_welcome_screen_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="imagemenuitem3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Account settings</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_account_settings_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Delete remote directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_delete_dir_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="imagemenuitem6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Synchronize remote directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_sync_remote_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Upload local directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_upload_dir_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Download directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_download_dir_activate"/>
+ </object>
+ </child>
+ <child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
@@ -102,7 +149,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox2">
+ <object class="GtkHBox" id="account_hbox">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_connect">
@@ -231,8 +278,238 @@
</packing>
</child>
<child>
- <object class="GtkHPaned" id="hpaned1">
+ <object class="GtkFrame" id="start_frame">
<property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment10">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Gbacker is a program to backup and restore files using a Gmail mail account.
+It uses the Gmail account as a remote file server.
+In contrast to other similar solutions like gdrive, gmailsync etc gbacker is fully compliant
+with the Gmail 'terms of use' and your not limited to a maximum of 500 uploads per 24 hours.
+With gbacker you can fully use the online storage space offered by Gmail.
+
+Use the menu 'Gbacker' to select the various tools.
+</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Welcome to gbacker</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="log_frame">
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="bottom_padding">8</property>
+ <property name="left_padding">8</property>
+ <property name="right_padding">8</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTextView" id="textview1">
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Log</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">8</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="pbar_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_pbar">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_pbar">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="sync_remote_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment7">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkFileChooserWidget" id="filechooserwidget1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Sync remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="delete_dir_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment6">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Delete remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="settings_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Account settings</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="upload_directory_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment8">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Upload local directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="download_directory_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment9">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Download remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHPaned" id="browser_paned">
<property name="can_focus">True</property>
<property name="position">300</property>
<property name="position_set">True</property>
@@ -406,74 +683,6 @@
<property name="position">2</property>
</packing>
</child>
- <child>
- <object class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="bottom_padding">8</property>
- <property name="left_padding">8</property>
- <property name="right_padding">8</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTextView" id="textview1">
- <property name="height_request">80</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Log</b></property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="padding">8</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame_pbar">
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment_pbar">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label_pbar">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
</object>
</child>
</object>
Modified: utils.py
===================================================================
--- utils.py 2009-12-13 09:56:19 UTC (rev 11)
+++ utils.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -22,6 +22,21 @@
import locale
import __builtin__
+from Constants import MESSAGEBODYITEMS
+
+def parse_body(text):
+ """Used to turn a string with email body items into a dictionary.
+ It returns the tuple (path,dictionary)"""
+ dict = {}
+ items = MESSAGEBODYITEMS
+
+ for line in text.split('\n'):
+ for k in items:
+ if k in line:
+ dict[k.replace(':', '', 1).strip()] = line.split(':', 1)[1].strip()
+ path = dict['path']
+ return dict, path
+
def set_locale(lang=None):
module_logger.debug("set_locale called with %s" % lang)
txt = ""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-27 08:54:07
|
Revision: 12
http://gbacker.svn.sourceforge.net/gbacker/?rev=12&view=rev
Author: stas_zytkiewicz
Date: 2009-12-27 08:53:59 +0000 (Sun, 27 Dec 2009)
Log Message:
-----------
Major updates
Modified Paths:
--------------
GuiGtk.py
Optparser.py
Worker.py
gbacker.py
gimap.py
glade/gui.ui
utils.py
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 09:56:19 UTC (rev 11)
+++ GuiGtk.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -74,6 +74,7 @@
self.parent = parent
glade_path = os.path.join(GLADEDIR, glade_path)
SimpleGladeApp.__init__(self, glade_path, root, domain)
+ self.current_frame = self.start_frame
# get our imap related stuff
self.ac = ImapAccount(options)
# Start a splash like dialog because the building of the empty tree can
@@ -108,7 +109,7 @@
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
self.remote_tree_widget = None
- self.window1.show_all()
+ self.window1.show()
# setup our threaded progressbar
self.pbar = gtk.ProgressBar()
self.pbar.set_pulse_step(0.1)
@@ -124,6 +125,33 @@
####### menu callbacks ##########
# Quit from the menu is connected to the on_window1_delete_event
+ def on_welcome_screen_activate(self, widget, *args):
+ self.logger.debug('on_welcome_screen_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_account_settings_activate(self, widget, *args):
+ self.logger.debug('on_account_settings_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_delete_dir_activate(self, widget, *args):
+ self.logger.debug('on_delete_dir_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_sync_remote_activate(self, widget, *args):
+ self.logger.debug('on_sync_remote_activate called with self.%s' % widget.get_name())
+ self.current_frame.hide()
+ self.sync_remote_frame.show()
+ self.current_frame = self.sync_remote_frame
+ return True
+
+ def on_upload_dir_activate(self, widget, *args):
+ self.logger.debug('on_upload_dir_activate called with self.%s' % widget.get_name())
+ return True
+
+ def on_download_dir_activate(self, widget, *args):
+ self.logger.debug('on_download_dir_activate called with self.%s' % widget.get_name())
+ return True
+
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
@@ -193,7 +221,7 @@
if self.remote_tree_widget:
self.remote_tree_widget.view.hide()
return True
-
+ ########### button callbacks filebrowser ##############
def on_button_arrow_right_clicked(self, widget, *args):
# upload selection
self.logger.debug('on_button_arrow_right_clicked called with self.%s' % widget.get_name())
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-13 09:56:19 UTC (rev 11)
+++ Optparser.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -51,7 +51,7 @@
help="Full path of the remote directory to download. Use the option -d to give a target destination for the download",
dest="restore")
self.add_option("-b", "--backup",
- help="Fuul path of the directory to backup.",
+ help="Full path of the directory to backup.",
dest="backup")
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
@@ -59,7 +59,12 @@
self.add_option("--rebuilddb",action="store_true",
help="Rebuilds the database in case it's corrupted. It will download all the subject lines from the Gmail messages in the account to rebuild the database table. Corruption of the database occurs when the program would crash or when you have a very flaky network connection.",
dest="rebuilddb")
-
+ self.add_option("-y", "--sync_remote",
+ help="Bring the remote directory, 'SYNC_REMOTE', in sync with the local directory. This will upload missing files and delete remote files that no longer available locally. Use this with care. If you sync a empty local directory all the remote files will be deleted.",
+ dest="sync_remote")
+ self.add_option("", "--delete_directory",
+ help="Full path of the remote directory, 'DELETE_DIRECTORY', to delete. This will completely remove the remote files and this deletion can not be reverted.",
+ dest="delete_directory")
(self.options, self.args) = self.parse_args()
def exit(self,*args):
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-13 09:56:19 UTC (rev 11)
+++ Worker.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -29,6 +29,7 @@
from gimap import ComposedMessage, Sender, ServerError, NoLoginError
from Constants import *
+from utils import parse_body
class ReadError(Exception):
pass
@@ -70,21 +71,10 @@
lines and values, the file path and the attachment.
the attachment is the raw file contants."""
payload = msg.get_payload()
- bodydict, path = self._parse_body(payload[1].as_string())
+ bodydict, path = parse_body(payload[1].as_string())
attachment = payload[0].get_payload(decode=True)
return bodydict, path, attachment
- def _parse_body(self, text):
- dict = {}
- items = MESSAGEBODYITEMS
-
- for line in text.split('\n'):
- for k in items:
- if k in line:
- dict[k.replace(':', '', 1).strip()] = line.split(':', 1)[1].strip()
- path = dict['path']
- return dict, path
-
class Uploader:
"""Sends a message and verifies that it is received properly by the server.
The message must be constructed by the Packager.
@@ -141,7 +131,18 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id and not self.sync:
+ if mesg_id and self.sync:
+ self.logger.debug("Found remote message: %s, checking if it differs" % mesg_id)
+ path, body= self.ac.fetch_body(mesg_id).items()[0]
+ remote_dict, path = parse_body('\n'.join(body))
+ local_dict, path = parse_body(msg.get_body())
+ if local_dict['creation'] == remote_dict['creation'] and \
+ local_dict['size'] == remote_dict['size']:
+ self.logger.debug("Files are the same, stopping the upload")
+ return ['OK', 'Files are the same, local file not send']
+ else:
+ self.logger.debug("Files differ, continuing the upload")
+ if mesg_id:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -163,10 +164,6 @@
self.logger.debug("Trashed message(s) with mesg_id(s): %s" % mesg_id)
# update dbase and empty tree
self.db.remove_message(mesg_subject_list)
- elif mesg_id and self.sync:
- self.logger.debug("Found remote message: %s, leaving it alone" % mesg_id)
- # TODO: check creationtime and size to determine if the file isn't changed
- return
else:
self.logger.debug("No old message found")
# DB will change the subject line by adding a table id, for example 'ID8'
@@ -178,14 +175,19 @@
maxtries = 3
tries = 0
while tries < maxtries :
- result = self.sender.send_message(new_msg)
+ try:
+ result = self.sender.send_message(new_msg)
+ except Exception, e:
+ self.logger.critical("Uncatched exception catched, error in the Sender class")
+ result = ('Fail', ' ')
if result[0] != 'OK':
self.logger.error("Failed to send the message, check the logs: %s" % result)
- tries += 1
self.logger.warning("Will try to send the message again, attempt %s" % tries)
tries += 1
self.logger.debug("reconnecting to server")
self.ac.logout()
+ self.logger.debug("Logged out, waiting 5 seconds before attempting to login again.")
+ time.sleep(5)
try:
self.ac.login_ssl()
except NoLoginError, e:
@@ -435,7 +437,7 @@
for k, v in subdict.items():
self.logger.debug("subject: %s" % k)
self.logger.debug("body:%s" % bodydict[k])
- d = packager._parse_body('\n'.join(bodydict[k]))[0]
+ d = parse_body('\n'.join(bodydict[k]))[0]
try:
self.ce(''' INSERT INTO messages VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
@@ -476,7 +478,7 @@
self.logger.debug("upload_new_message called with:%s" % mesg)
# unpack the mesg
p = Packager()
- d, path = p._parse_body(mesg.get_body())
+ d, path = parse_body(mesg.get_body())
self.ce(''' INSERT INTO messages VALUES
( NULL, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
(self.account, d['path'], d['current_dir'], d['creation'], d['up_load'],\
@@ -652,7 +654,7 @@
# TODO: implement tags
tag = ''
info = ("path: %s" % filename,\
- "creation: %s" % time.ctime(statinfo.st_mtime),\
+ "creation: %s" % statinfo.st_mtime,\
"size: %s" % str(max(1, statinfo.st_size/1024))+' KB',\
"up_load: %s" % time.asctime(), \
"encrypt: %s" % encrypt,\
@@ -844,7 +846,7 @@
else:
return True
- def upload_directory(self, directory, hidden=False):
+ def upload_directory(self, directory, hidden=False, sync=False):
"""Uploads the complete directory to the Gmail Drafts folder.
The packager will create a email.Message object with the proper subject line.
It then passes the message to the uploader which will append it to the drafts folder
@@ -855,8 +857,9 @@
The dbase update is done by uploader.
Returns True on success and None on failure.
"""
+ #TODO: implement @hidden
self.logger.debug("Start uploading %s" % directory)
- self.uploader = Uploader(self.ac, self.db, self.treebuilder)
+ self.uploader = Uploader(self.ac, self.db, self.treebuilder, sync)
self.packager = Packager()
self.directoryreader = DirectoryReader(directory)
@@ -903,7 +906,7 @@
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails.
"""
- # strip the emptytree part form the path
+ # strip the emptytree part form the path in case we are called from the GUI
directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for %s##" % directory)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT %s##)' % directory)
@@ -956,11 +959,11 @@
When there's no difference None is returned.
"""
# first get a list with remote filenames form the empty tree
-
remotefilelist = self.treebuilder.get_dir_contents(directory)
+ # then one from the local tree
self.directoryreader = DirectoryReader(directory)
localfilelist = self.directoryreader.get_filenames_from_dir()
-
+ # diff them
s = set(localfilelist)
locallist = []
for i in s.difference(remotefilelist):
@@ -979,6 +982,16 @@
available locally.
Use this with care. If you sync a empty local directory all the remote
files will be deleted."""
+ # first we get a diff list
+ difflist = self.diff(directory)
+ self.logger.debug("Found difference list: %s" % difflist)
+ # here we remove all the paths that are only in remote.
+ for place, path in difflist:
+ if place == 'remote':
+ self.delete_remote_file(path)
+ # the only local files will be handled by the uploader as well as the
+ # changed local files.
+ self.upload_directory(directory, sync=True)
def sync_local(self, directory, dest):
"""Update a local directory with the remote directory.
@@ -1019,13 +1032,13 @@
w = Worker(ac)
#w.rebuild_dbase()
#w.upload_directory('/home/stas/temp/test_pics')
- #w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
+ #w.upload_directory('/home/stas/temp/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
# print k, v
- #w.download_directory('/home/stas/SVN-WORK/gbacker/TestDir', '/tmp')
- #w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
+ #w.download_directory('/home/stas/temp/TestDir', '/tmp')
+ #w.download_file('/home/stas/temp/TestDir/test1.txt', '/tmp')
#w.build_remote_tree()
#w.delete_remote_dir(os.path.abspath('TestDir'))
@@ -1034,9 +1047,12 @@
# for i in w.diff(os.path.abspath('TestDir')):
# print i
-# rr = RemoteDirectoryReader(ac, '/home/stas/SVN-WORK/gbacker')
+# rr = RemoteDirectoryReader(ac, '/home/stas/temp')
# files = rr.get_filenames_from_dir()
# print files
+
+ w.sync_remote('/home/stas/temp/TestDir')
+
raw_input("hit any key to stop")
w.stop()
ac.logout()
Modified: gbacker.py
===================================================================
--- gbacker.py 2009-12-13 09:56:19 UTC (rev 11)
+++ gbacker.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -51,7 +51,8 @@
# When the options backup or restore are given we don't start the gui but
# start Worker our selfs.
-if CMD_Options.backup or CMD_Options.restore:
+if CMD_Options.backup or CMD_Options.restore or CMD_Options.sync_remote or\
+ CMD_Options.delete_directory:
from gimap import ImapAccount
from Worker import Worker
ac = ImapAccount()
@@ -61,6 +62,10 @@
w.upload_directory(CMD_Options.backup)
elif CMD_Options.restore:
w.download_directory(CMD_Options.restore, CMD_Options.destination)
+ elif CMD_Options.sync_remote:
+ w.sync_remote(CMD_Options.sync_remote)
+ elif CMD_Options.delete_directory:
+ w.delete_remote_dir(CMD_Options.delete_directory)
elif CMD_Options.rebuilddb:
from gimap import ImapAccount
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-13 09:56:19 UTC (rev 11)
+++ gimap.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -21,7 +21,7 @@
import socket
socket.setdefaulttimeout(10)
-
+from ssl import SSLError
import imaplib
import time
import sys
@@ -102,7 +102,8 @@
"""atexit func to make sure we always do a proper gmail logout"""
try:
if self.AC:
- self.logout()
+ self.AC.close()
+ self.AC.logout()
except Exception, e:
self.logger.debug("_panic_logout raises and exception: %s" % e)
@@ -207,7 +208,7 @@
self.logger.debug("logout called")
if self.AC:
try:
- #self.AC.close()
+ self.AC.close()
self.AC.logout()
except Exception, e:
self.logger.error("Error while closing connection: %s" % e)
@@ -511,61 +512,6 @@
raise ServerError,"Error parsing getquota string, Gmail probably changed the getquotaroot response."
return data
- ####### various abstraction methods to mimic a real filesystem
-# def os_path_isdir(self, path):
-# """os.path.isdir replacement for testing a remote dir."""
-# ids = self.get_id('[Gmail]/All Mail','(SUBJECT "%s##")' % path)
-# if ids:
-# for mesg_id in ids.split(','):
-# try:
-# data = self.fetch_subject(mesg_id)
-# except ServerError, e:
-# self.logger.error("Failed to download the subject header from message with mesg_id: %s, %s" % (mesg_id, e))
-# raise ReadError
-# else:
-# dirname, fname = data[0][1].split('##')
-# dirname = dirname.split('Subject:')[1].strip()
-# if dirname == path:
-# return True
-# else:
-# return False
-# return False
-#
-## def os_path_join(self, *files):
-## """os.path.join replacement for handling paths returnt by a gimap method ."""
-## pass
-#
-# def os_listdir(self, dir):
-# """os.listdir replacement for list the contents of a remote directory."""
-# self.logger.debug("Getting contents of remote directory: %s" % dir)
-# try:
-# ids = self.get_id('[Gmail]/All Mail','(SUBJECT "%s##")' % dir)
-# except ServerError, e:
-# self.logger.error("Failed to get ids: %s" % e)
-# if not ids:
-# return []
-# filelist = []
-# buckets = {}
-# for mesg_id in ids.split(','):
-# try:
-# data = self.fetch_subject(mesg_id)
-# except ServerError, e:
-# self.logger.error("Failed to download the subject header from message with mesg_id: %s, %s" % (mesg_id, e))
-# raise ReadError
-# else:
-# dirname, fname = data[0][1].split('##')
-# dirname = dirname.split('Subject:')[1].strip()
-# fname = fname.strip()
-# # don't include contents of sub dirs
-# if dir == dirname:
-# # fname is part of dir
-# filelist.append(fname)
-# elif '/' in dirname.replace(dir, '', 1):
-# # dirname is a subdirectory
-# buckets[dirname] = None
-# filelist += buckets.keys()
-# return filelist
-
class Sender:
"""Object which uploads a message to the Gmail imap server and appends it to the Drafts folder."""
def __init__(self, server, imap_user, imap_pass):
@@ -585,7 +531,7 @@
emailmesg = mesg.get_message()
try:
result = self.server.append(draftsbox, '', '', emailmesg.as_string())
- except self.server.abort, e:
+ except (self.server.abort, SSLError), e:
self.logger.error("failed to append message: %s" % e)
result = ['Timeout', str(e)]
if result[0] != 'OK':
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 09:56:19 UTC (rev 11)
+++ glade/gui.ui 2009-12-27 08:53:59 UTC (rev 12)
@@ -23,6 +23,53 @@
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
+ <object class="GtkMenuItem" id="imagemenuitem1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Welcome screen</property>
+ <signal name="activate" handler="on_welcome_screen_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="imagemenuitem3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Account settings</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_account_settings_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Delete remote directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_delete_dir_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="imagemenuitem6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Synchronize remote directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_sync_remote_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Upload local directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_upload_dir_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Download directory</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_download_dir_activate"/>
+ </object>
+ </child>
+ <child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
@@ -102,7 +149,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox2">
+ <object class="GtkHBox" id="account_hbox">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_connect">
@@ -231,8 +278,238 @@
</packing>
</child>
<child>
- <object class="GtkHPaned" id="hpaned1">
+ <object class="GtkFrame" id="start_frame">
<property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment10">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Gbacker is a program to backup and restore files using a Gmail mail account.
+It uses the Gmail account as a remote file server.
+In contrast to other similar solutions like gdrive, gmailsync etc gbacker is fully compliant
+with the Gmail 'terms of use' and your not limited to a maximum of 500 uploads per 24 hours.
+With gbacker you can fully use the online storage space offered by Gmail.
+
+Use the menu 'Gbacker' to select the various tools.
+</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Welcome to gbacker</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="log_frame">
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="bottom_padding">8</property>
+ <property name="left_padding">8</property>
+ <property name="right_padding">8</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTextView" id="textview1">
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Log</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">8</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="pbar_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_pbar">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_pbar">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="sync_remote_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment7">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkFileChooserWidget" id="filechooserwidget1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Sync remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="delete_dir_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment6">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Delete remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="settings_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Account settings</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="upload_directory_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment8">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Upload local directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="download_directory_frame">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment9">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Download remote directory</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHPaned" id="browser_paned">
<property name="can_focus">True</property>
<property name="position">300</property>
<property name="position_set">True</property>
@@ -406,74 +683,6 @@
<property name="position">2</property>
</packing>
</child>
- <child>
- <object class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="bottom_padding">8</property>
- <property name="left_padding">8</property>
- <property name="right_padding">8</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTextView" id="textview1">
- <property name="height_request">80</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Log</b></property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="padding">8</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame_pbar">
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment_pbar">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label_pbar">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
</object>
</child>
</object>
Modified: utils.py
===================================================================
--- utils.py 2009-12-13 09:56:19 UTC (rev 11)
+++ utils.py 2009-12-27 08:53:59 UTC (rev 12)
@@ -22,6 +22,21 @@
import locale
import __builtin__
+from Constants import MESSAGEBODYITEMS
+
+def parse_body(text):
+ """Used to turn a string with email body items into a dictionary.
+ It returns the tuple (path,dictionary)"""
+ dict = {}
+ items = MESSAGEBODYITEMS
+
+ for line in text.split('\n'):
+ for k in items:
+ if k in line:
+ dict[k.replace(':', '', 1).strip()] = line.split(':', 1)[1].strip()
+ path = dict['path']
+ return dict, path
+
def set_locale(lang=None):
module_logger.debug("set_locale called with %s" % lang)
txt = ""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 09:56:31
|
Revision: 11
http://gbacker.svn.sourceforge.net/gbacker/?rev=11&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 09:56:19 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Removed stuff from the gui.
Added extra checks and catches
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Worker.py
gimap.py
glade/gui.ui
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-13 07:13:34 UTC (rev 10)
+++ FileBrowserWidget.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -63,8 +63,12 @@
self.show_rules_hint = True
self.multiple_selection = True
self.logger.debug("testing is dir: %s" % root)
- if root != None and os.path.isdir(root):
- self.root = root
+ self.root = root
+ self._setup()
+
+ def _setup(self):
+ if self.root != None and os.path.isdir(self.root):
+ pass
else:
self.logger.debug("Can't find %s, set root to '/'" % root)
self.root = '/'
@@ -526,8 +530,18 @@
# TODO: what if we have paths that don't start in the users home dir
# like trees rooted in an external HD ??
# In create_root the decision is made which tree to show.
+
+ def _setup(self):
+ if self.root != None and os.path.isdir(self.root):
+ pass
+ else:
+ self.logger.debug("Can't find %s, this means there are probably no remote files." % self.root)
+ self.view, self.scrolled = self.make_view()
+ return
+ self.view, self.scrolled = self.make_view()
+ self.create_new()
+ self.create_popup()
-
def create_root(self):
"""sets the root for the tree widget.
It will strip parts of the root to prevent large trees of single dirs.
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 07:13:34 UTC (rev 10)
+++ GuiGtk.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -59,7 +59,7 @@
from Constants import *
from FileBrowserWidget import TreeFileBrowser, RemoteTreeFileBrowser
from gimap import ImapAccount, NoLoginError
-from Worker import Worker # Worker is setup in on_button_connect_clicked
+from Worker import Worker, DirectoryReader # Worker is setup in on_button_connect_clicked
# ignore warnings as it isn't useful for the user to see them.
# At this moment, release 0.8, the gtk builder in SimpleGladeApp raises warnings
@@ -104,7 +104,7 @@
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
self.guilogger.write(_("Start logger"))
# add the treebrowser widget
- self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
+ self.local_tree_widget = TreeFileBrowser(self,'/')
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
self.remote_tree_widget = None
@@ -113,6 +113,7 @@
self.pbar = gtk.ProgressBar()
self.pbar.set_pulse_step(0.1)
self.alignment_pbar.add(self.pbar)
+ self.pbp = None # will become a threaded progressbar pulser in upload/download
def on_window1_delete_event(self, widget, *args):
self.logger.debug('on_window1_delete_event called with self.%s' % widget.get_name())
@@ -122,11 +123,7 @@
####### menu callbacks ##########
# Quit from the menu is connected to the on_window1_delete_event
- def on_preferences_activated(self, widget, *args):
- self.logger.debug('on_preferences_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
+
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
@@ -213,12 +210,16 @@
self.guilogger.write(_("%s files selected, starting to upload" % len(selectedfiles)))
self.frame_pbar.show_all()
+ self.pp = PbarPulser(self.pbar)
+ self.pp.start()
for item in selectedfiles:
if os.path.isdir(item):
- for file in glob.glob(os.path.join(item, '*')):
+ d = DirectoryReader(item)
+ for file, info in d.reader():
self._upload_file(file)
else:
self._upload_file(item)
+ self.pp.stop()
self.frame_pbar.hide()
return True
@@ -246,15 +247,15 @@
return True
else:
self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
- pbp = PbarPulser(self.pbar)
- pbp.start()
+ self.pbp = PbarPulser(self.pbar)
+ self.pbp.start()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
self._download_file(file, target)
else:
self._download_file(item, target)
- pbp.stop()
+ self.pbp.stop()
self.frame_pbar.hide()
return True
@@ -303,18 +304,17 @@
self.guilogger.write(_("Deleting %s" % path))
if os.path.isdir(path):
self.worker.delete_remote_dir(path)
- else:
+ elif os.path.isfile(path):
self.worker.delete_remote_file(path)
self.guilogger.write(_("done"))
######## Various internally used methods ############
def _upload_file(self, file):
+ if os.path.isdir(file):
+ return
self.guilogger.write(_("Uploading %s" % file))
- pp = PbarPulser(self.pbar)
- pp.start()
result = self.worker.upload_file(file)
- pp.stop()
if result:
self.guilogger.write(_("done."))
else:
@@ -333,6 +333,8 @@
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
self.guilogger.write(_("Stopping all processes"))
+ if self.pbp:
+ self.pbp.stop()
try:
self.worker.stop()
except:
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-13 07:13:34 UTC (rev 10)
+++ Worker.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -77,6 +77,7 @@
def _parse_body(self, text):
dict = {}
items = MESSAGEBODYITEMS
+
for line in text.split('\n'):
for k in items:
if k in line:
@@ -140,7 +141,7 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id and not sync:
+ if mesg_id and not self.sync:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -257,7 +258,7 @@
if e.errno == 2:
pass
else:
- self.logger.debug("failed to remove empty diretory tree: %s, %s %s" % (root, e.errno, e.strerror))
+ self.logger.debug("failed to remove empty directory tree: %s, %s %s" % (root, e.errno, e.strerror))
except Exception, e:
self.logger.warning("Error while trying to remove empty tree: %s,%s" % (root, e))
@@ -398,7 +399,7 @@
"""Will rebuild dbase table in case the table is corrupted.
Corruption will mostly occur when gbacker crashes or has network problems.
We don't trust the empty tree so we will download all the messages headers
- and bodies, not the attachments. This makes rebuilding very fast.
+ and bodies, not the attachments. This makes rebuilding relatively fast.
A copy of the dbase file is made and FinalError exceptions are raised if
anything goes wrong. The caller must stop to prevent corruption of the
remote messages.
@@ -432,8 +433,10 @@
subtotal = 0
totalrows = len(subdict.keys())
for k, v in subdict.items():
+ self.logger.debug("subject: %s" % k)
+ self.logger.debug("body:%s" % bodydict[k])
+ d = packager._parse_body('\n'.join(bodydict[k]))[0]
try:
- d = packager._parse_body('\n'.join(bodydict[k]))[0]
self.ce(''' INSERT INTO messages VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
(d['id'],self.account, d['path'], d['current_dir'], d['creation'],\
@@ -442,6 +445,8 @@
self.logger.critical("Failed to insert row: %s" % e)
txt = "Possible corrupted email messages, I don't have a solution. You could try to contact the gbacker mailinglist for help."
self.logger.critical(txt)
+ txt = "The values that failed to insert where: %s" % d
+ self.logger.critical(txt)
txt = "%s Error message:%s" % (txt, str(e))
raise FinalError, txt
else:
@@ -735,6 +740,9 @@
self.logger.debug("get email ids")
mesg_ids = self.ac.get_id('', 'ALL')
self.logger.warning("found ids: %s" % mesg_ids)
+ if not mesg_ids:
+ self.logger.warning("No messages found, nothing to rebuild")
+ return
self.logger.warning("get message subjects")
subjectdict = self.ac.fetch_subject(mesg_ids)
self.logger.warning("get message body text, this can take some time on larger backups.")
@@ -1010,7 +1018,7 @@
server = ac.login_ssl()
w = Worker(ac)
#w.rebuild_dbase()
- w.upload_directory('/home/stas/temp/test_pics')
+ #w.upload_directory('/home/stas/temp/test_pics')
#w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-13 07:13:34 UTC (rev 10)
+++ gimap.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -354,6 +354,10 @@
subdict = {}
for item in self._fetch_item(mesg_id, 'subject'):
if len(item) > 1:
+ # spaces in file names, and thus in the subject line are replaced by
+ # '\r\n ' ?? WTF, we don't do that, Gmail perhaps ??
+ # we remove them otherwise the subject line differ from the body path line
+ item =(item[0], item[1].replace('\r\n', ''))
root, file, dbid = item[1].strip().replace('Subject: ','',1).split('##')
dbid = int(dbid[2:])
subdict[file] = (root, file, dbid)
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 07:13:34 UTC (rev 10)
+++ glade/gui.ui 2009-12-13 09:56:19 UTC (rev 11)
@@ -17,21 +17,12 @@
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Ibsig</property>
+ <property name="label" translatable="yes">_Gbacker</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem1">
- <property name="label">gtk-preferences</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_preferences_activated"/>
- </object>
- </child>
- <child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
@@ -213,6 +204,25 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_sync">
+ <property name="label" translatable="yes">Sync</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Bring the remote files in sync with the
+local files. This means that when the uploaded
+local files and the remote files are the same
+they will not be replaced.
+Files are considered the same when the size
+and creation time are the same.</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_checkbutton_sync_toggled"/>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -288,6 +298,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Upload local selected directories and files
+to the remote server.
+Files will be stored with their complete path.</property>
<signal name="clicked" handler="on_button_arrow_right_clicked"/>
<child>
<object class="GtkImage" id="image1">
@@ -302,11 +315,18 @@
</packing>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkButton" id="button2">
<property name="width_request">40</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Download remote selected directory and files to the selected
+local directory. If no local directory is selected as the root for
+the remote files the remote files will be downloaded to their
+original path.</property>
<signal name="clicked" handler="on_button_arrow_left_clicked"/>
<child>
<object class="GtkImage" id="image2">
@@ -317,16 +337,13 @@
</object>
<packing>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
- <child type="label_item">
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 09:56:27
|
Revision: 11
http://gbacker.svn.sourceforge.net/gbacker/?rev=11&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 09:56:19 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
Removed stuff from the gui.
Added extra checks and catches
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Worker.py
gimap.py
glade/gui.ui
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-13 07:13:34 UTC (rev 10)
+++ FileBrowserWidget.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -63,8 +63,12 @@
self.show_rules_hint = True
self.multiple_selection = True
self.logger.debug("testing is dir: %s" % root)
- if root != None and os.path.isdir(root):
- self.root = root
+ self.root = root
+ self._setup()
+
+ def _setup(self):
+ if self.root != None and os.path.isdir(self.root):
+ pass
else:
self.logger.debug("Can't find %s, set root to '/'" % root)
self.root = '/'
@@ -526,8 +530,18 @@
# TODO: what if we have paths that don't start in the users home dir
# like trees rooted in an external HD ??
# In create_root the decision is made which tree to show.
+
+ def _setup(self):
+ if self.root != None and os.path.isdir(self.root):
+ pass
+ else:
+ self.logger.debug("Can't find %s, this means there are probably no remote files." % self.root)
+ self.view, self.scrolled = self.make_view()
+ return
+ self.view, self.scrolled = self.make_view()
+ self.create_new()
+ self.create_popup()
-
def create_root(self):
"""sets the root for the tree widget.
It will strip parts of the root to prevent large trees of single dirs.
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 07:13:34 UTC (rev 10)
+++ GuiGtk.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -59,7 +59,7 @@
from Constants import *
from FileBrowserWidget import TreeFileBrowser, RemoteTreeFileBrowser
from gimap import ImapAccount, NoLoginError
-from Worker import Worker # Worker is setup in on_button_connect_clicked
+from Worker import Worker, DirectoryReader # Worker is setup in on_button_connect_clicked
# ignore warnings as it isn't useful for the user to see them.
# At this moment, release 0.8, the gtk builder in SimpleGladeApp raises warnings
@@ -104,7 +104,7 @@
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
self.guilogger.write(_("Start logger"))
# add the treebrowser widget
- self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
+ self.local_tree_widget = TreeFileBrowser(self,'/')
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
self.remote_tree_widget = None
@@ -113,6 +113,7 @@
self.pbar = gtk.ProgressBar()
self.pbar.set_pulse_step(0.1)
self.alignment_pbar.add(self.pbar)
+ self.pbp = None # will become a threaded progressbar pulser in upload/download
def on_window1_delete_event(self, widget, *args):
self.logger.debug('on_window1_delete_event called with self.%s' % widget.get_name())
@@ -122,11 +123,7 @@
####### menu callbacks ##########
# Quit from the menu is connected to the on_window1_delete_event
- def on_preferences_activated(self, widget, *args):
- self.logger.debug('on_preferences_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
+
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
@@ -213,12 +210,16 @@
self.guilogger.write(_("%s files selected, starting to upload" % len(selectedfiles)))
self.frame_pbar.show_all()
+ self.pp = PbarPulser(self.pbar)
+ self.pp.start()
for item in selectedfiles:
if os.path.isdir(item):
- for file in glob.glob(os.path.join(item, '*')):
+ d = DirectoryReader(item)
+ for file, info in d.reader():
self._upload_file(file)
else:
self._upload_file(item)
+ self.pp.stop()
self.frame_pbar.hide()
return True
@@ -246,15 +247,15 @@
return True
else:
self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
- pbp = PbarPulser(self.pbar)
- pbp.start()
+ self.pbp = PbarPulser(self.pbar)
+ self.pbp.start()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
self._download_file(file, target)
else:
self._download_file(item, target)
- pbp.stop()
+ self.pbp.stop()
self.frame_pbar.hide()
return True
@@ -303,18 +304,17 @@
self.guilogger.write(_("Deleting %s" % path))
if os.path.isdir(path):
self.worker.delete_remote_dir(path)
- else:
+ elif os.path.isfile(path):
self.worker.delete_remote_file(path)
self.guilogger.write(_("done"))
######## Various internally used methods ############
def _upload_file(self, file):
+ if os.path.isdir(file):
+ return
self.guilogger.write(_("Uploading %s" % file))
- pp = PbarPulser(self.pbar)
- pp.start()
result = self.worker.upload_file(file)
- pp.stop()
if result:
self.guilogger.write(_("done."))
else:
@@ -333,6 +333,8 @@
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
self.guilogger.write(_("Stopping all processes"))
+ if self.pbp:
+ self.pbp.stop()
try:
self.worker.stop()
except:
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-13 07:13:34 UTC (rev 10)
+++ Worker.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -77,6 +77,7 @@
def _parse_body(self, text):
dict = {}
items = MESSAGEBODYITEMS
+
for line in text.split('\n'):
for k in items:
if k in line:
@@ -140,7 +141,7 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id and not sync:
+ if mesg_id and not self.sync:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -257,7 +258,7 @@
if e.errno == 2:
pass
else:
- self.logger.debug("failed to remove empty diretory tree: %s, %s %s" % (root, e.errno, e.strerror))
+ self.logger.debug("failed to remove empty directory tree: %s, %s %s" % (root, e.errno, e.strerror))
except Exception, e:
self.logger.warning("Error while trying to remove empty tree: %s,%s" % (root, e))
@@ -398,7 +399,7 @@
"""Will rebuild dbase table in case the table is corrupted.
Corruption will mostly occur when gbacker crashes or has network problems.
We don't trust the empty tree so we will download all the messages headers
- and bodies, not the attachments. This makes rebuilding very fast.
+ and bodies, not the attachments. This makes rebuilding relatively fast.
A copy of the dbase file is made and FinalError exceptions are raised if
anything goes wrong. The caller must stop to prevent corruption of the
remote messages.
@@ -432,8 +433,10 @@
subtotal = 0
totalrows = len(subdict.keys())
for k, v in subdict.items():
+ self.logger.debug("subject: %s" % k)
+ self.logger.debug("body:%s" % bodydict[k])
+ d = packager._parse_body('\n'.join(bodydict[k]))[0]
try:
- d = packager._parse_body('\n'.join(bodydict[k]))[0]
self.ce(''' INSERT INTO messages VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?) ''' ,\
(d['id'],self.account, d['path'], d['current_dir'], d['creation'],\
@@ -442,6 +445,8 @@
self.logger.critical("Failed to insert row: %s" % e)
txt = "Possible corrupted email messages, I don't have a solution. You could try to contact the gbacker mailinglist for help."
self.logger.critical(txt)
+ txt = "The values that failed to insert where: %s" % d
+ self.logger.critical(txt)
txt = "%s Error message:%s" % (txt, str(e))
raise FinalError, txt
else:
@@ -735,6 +740,9 @@
self.logger.debug("get email ids")
mesg_ids = self.ac.get_id('', 'ALL')
self.logger.warning("found ids: %s" % mesg_ids)
+ if not mesg_ids:
+ self.logger.warning("No messages found, nothing to rebuild")
+ return
self.logger.warning("get message subjects")
subjectdict = self.ac.fetch_subject(mesg_ids)
self.logger.warning("get message body text, this can take some time on larger backups.")
@@ -1010,7 +1018,7 @@
server = ac.login_ssl()
w = Worker(ac)
#w.rebuild_dbase()
- w.upload_directory('/home/stas/temp/test_pics')
+ #w.upload_directory('/home/stas/temp/test_pics')
#w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-13 07:13:34 UTC (rev 10)
+++ gimap.py 2009-12-13 09:56:19 UTC (rev 11)
@@ -354,6 +354,10 @@
subdict = {}
for item in self._fetch_item(mesg_id, 'subject'):
if len(item) > 1:
+ # spaces in file names, and thus in the subject line are replaced by
+ # '\r\n ' ?? WTF, we don't do that, Gmail perhaps ??
+ # we remove them otherwise the subject line differ from the body path line
+ item =(item[0], item[1].replace('\r\n', ''))
root, file, dbid = item[1].strip().replace('Subject: ','',1).split('##')
dbid = int(dbid[2:])
subdict[file] = (root, file, dbid)
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 07:13:34 UTC (rev 10)
+++ glade/gui.ui 2009-12-13 09:56:19 UTC (rev 11)
@@ -17,21 +17,12 @@
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Ibsig</property>
+ <property name="label" translatable="yes">_Gbacker</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem1">
- <property name="label">gtk-preferences</property>
- <property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_preferences_activated"/>
- </object>
- </child>
- <child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
@@ -213,6 +204,25 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton_sync">
+ <property name="label" translatable="yes">Sync</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Bring the remote files in sync with the
+local files. This means that when the uploaded
+local files and the remote files are the same
+they will not be replaced.
+Files are considered the same when the size
+and creation time are the same.</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_checkbutton_sync_toggled"/>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -288,6 +298,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Upload local selected directories and files
+to the remote server.
+Files will be stored with their complete path.</property>
<signal name="clicked" handler="on_button_arrow_right_clicked"/>
<child>
<object class="GtkImage" id="image1">
@@ -302,11 +315,18 @@
</packing>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkButton" id="button2">
<property name="width_request">40</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Download remote selected directory and files to the selected
+local directory. If no local directory is selected as the root for
+the remote files the remote files will be downloaded to their
+original path.</property>
<signal name="clicked" handler="on_button_arrow_left_clicked"/>
<child>
<object class="GtkImage" id="image2">
@@ -317,16 +337,13 @@
</object>
<packing>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
- <child type="label_item">
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 07:13:47
|
Revision: 10
http://gbacker.svn.sourceforge.net/gbacker/?rev=10&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 07:13:34 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
removed stuff from the gui which will never be implemented.
Modified Paths:
--------------
GuiGtk.py
glade/gui.ui
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 06:56:59 UTC (rev 9)
+++ GuiGtk.py 2009-12-13 07:13:34 UTC (rev 10)
@@ -127,44 +127,6 @@
InfoDialog("Not yet implemented")
return True
- def on_local_new_directory_activated(self, widget, *args):
- self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_rename_activated(self, widget, *args):
- self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_delete_activated(self, widget, *args):
- self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_upload_directory_activated(self, widget, *args):
- self.logger.debug('on_local_upload_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_new_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_rename_activated(self, widget, *args):
- self.logger.debug('on_remote_rename_activated called with self.%s' % widget.get_name())
- return True
-
- def on_remote_delete_activated(self, widget, *args):
- self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_download_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_download_directory_activated called with self.%s' % widget.get_name())
- return True
-
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 06:56:59 UTC (rev 9)
+++ glade/gui.ui 2009-12-13 07:13:34 UTC (rev 10)
@@ -45,102 +45,6 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="menuitem2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Local</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu2">
- <property name="visible">True</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem6">
- <property name="label" translatable="yes">New Directory</property>
- <property name="visible">True</property>
- <property name="image">image5</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_new_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label" translatable="yes">Rename</property>
- <property name="visible">True</property>
- <property name="image">image6</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_rename_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label" translatable="yes">Delete</property>
- <property name="visible">True</property>
- <property name="image">image7</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_delete_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem9">
- <property name="label" translatable="yes">Upload Directory</property>
- <property name="visible">True</property>
- <property name="image">image8</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_upload_directory_activated"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Remote</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu4">
- <property name="visible">True</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem3">
- <property name="label" translatable="yes">New Directory</property>
- <property name="visible">True</property>
- <property name="image">image9</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_new_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem11">
- <property name="label" translatable="yes">Rename</property>
- <property name="visible">True</property>
- <property name="image">image10</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_rename_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem12">
- <property name="label" translatable="yes">Delete</property>
- <property name="visible">True</property>
- <property name="image">image11</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_delete_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem14">
- <property name="label" translatable="yes">Dowload Directory</property>
- <property name="visible">True</property>
- <property name="image">image12</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_download_directory_activated"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">L_og</property>
@@ -558,47 +462,6 @@
</object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkListStore" id="liststore2"/>
- <object class="GtkImage" id="image5">
- <property name="visible">True</property>
- <property name="yalign">0.49000000953674316</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image6">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image7">
- <property name="visible">True</property>
- <property name="stock">gtk-delete</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image8">
- <property name="visible">True</property>
- <property name="stock">gtk-sort-ascending</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image9">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image10">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image11">
- <property name="visible">True</property>
- <property name="stock">gtk-delete</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image12">
- <property name="visible">True</property>
- <property name="stock">gtk-sort-descending</property>
- <property name="icon-size">1</property>
- </object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 07:13:45
|
Revision: 10
http://gbacker.svn.sourceforge.net/gbacker/?rev=10&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 07:13:34 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
removed stuff from the gui which will never be implemented.
Modified Paths:
--------------
GuiGtk.py
glade/gui.ui
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-13 06:56:59 UTC (rev 9)
+++ GuiGtk.py 2009-12-13 07:13:34 UTC (rev 10)
@@ -127,44 +127,6 @@
InfoDialog("Not yet implemented")
return True
- def on_local_new_directory_activated(self, widget, *args):
- self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_rename_activated(self, widget, *args):
- self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_delete_activated(self, widget, *args):
- self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_local_upload_directory_activated(self, widget, *args):
- self.logger.debug('on_local_upload_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_new_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_rename_activated(self, widget, *args):
- self.logger.debug('on_remote_rename_activated called with self.%s' % widget.get_name())
- return True
-
- def on_remote_delete_activated(self, widget, *args):
- self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
- InfoDialog("Not yet implemented")
- return True
-
- def on_remote_download_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_download_directory_activated called with self.%s' % widget.get_name())
- return True
-
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
InfoDialog("Not yet implemented")
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-12-13 06:56:59 UTC (rev 9)
+++ glade/gui.ui 2009-12-13 07:13:34 UTC (rev 10)
@@ -45,102 +45,6 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="menuitem2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Local</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu2">
- <property name="visible">True</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem6">
- <property name="label" translatable="yes">New Directory</property>
- <property name="visible">True</property>
- <property name="image">image5</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_new_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label" translatable="yes">Rename</property>
- <property name="visible">True</property>
- <property name="image">image6</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_rename_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label" translatable="yes">Delete</property>
- <property name="visible">True</property>
- <property name="image">image7</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_delete_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem9">
- <property name="label" translatable="yes">Upload Directory</property>
- <property name="visible">True</property>
- <property name="image">image8</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_local_upload_directory_activated"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Remote</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu4">
- <property name="visible">True</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem3">
- <property name="label" translatable="yes">New Directory</property>
- <property name="visible">True</property>
- <property name="image">image9</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_new_directory_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem11">
- <property name="label" translatable="yes">Rename</property>
- <property name="visible">True</property>
- <property name="image">image10</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_rename_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem12">
- <property name="label" translatable="yes">Delete</property>
- <property name="visible">True</property>
- <property name="image">image11</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_delete_activated"/>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem14">
- <property name="label" translatable="yes">Dowload Directory</property>
- <property name="visible">True</property>
- <property name="image">image12</property>
- <property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_download_directory_activated"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">L_og</property>
@@ -558,47 +462,6 @@
</object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkListStore" id="liststore2"/>
- <object class="GtkImage" id="image5">
- <property name="visible">True</property>
- <property name="yalign">0.49000000953674316</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image6">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image7">
- <property name="visible">True</property>
- <property name="stock">gtk-delete</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image8">
- <property name="visible">True</property>
- <property name="stock">gtk-sort-ascending</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image9">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image10">
- <property name="visible">True</property>
- <property name="stock">gtk-new</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image11">
- <property name="visible">True</property>
- <property name="stock">gtk-delete</property>
- <property name="icon-size">1</property>
- </object>
- <object class="GtkImage" id="image12">
- <property name="visible">True</property>
- <property name="stock">gtk-sort-descending</property>
- <property name="icon-size">1</property>
- </object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 06:57:08
|
Revision: 9
http://gbacker.svn.sourceforge.net/gbacker/?rev=9&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 06:56:59 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
More work done to make worker more stable and
added the ability to reconnect in case of network trouble.
Also a socket timeout was added.
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Worker.py
gimap.py
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-10 12:44:35 UTC (rev 8)
+++ FileBrowserWidget.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -28,6 +28,7 @@
import os
import gtk
import gobject
+import logging
class TreeFileBrowser(gobject.GObject):
""" A widget that implements a tree-like file browser, like the
@@ -52,7 +53,8 @@
""" root is where we want the tree initialized """
self.parent = parent
gobject.GObject.__init__(self)
-
+ self.logger = logging.getLogger('gbacker.FileBrowserWidget.TreeFileBrowser')
+ self.logger.debug("TreeFileBrowser created with root: %s" % root)
self.show_hidden = False
# set to false to show all files
self.show_only_dirs = False
@@ -60,10 +62,11 @@
self.sort_dir_files = True
self.show_rules_hint = True
self.multiple_selection = True
-
+ self.logger.debug("testing is dir: %s" % root)
if root != None and os.path.isdir(root):
self.root = root
else:
+ self.logger.debug("Can't find %s, set root to '/'" % root)
self.root = '/'
self.view, self.scrolled = self.make_view()
@@ -366,14 +369,16 @@
It will strip parts of the root to prevent large trees of single dirs.
"""
model = self.view.get_model()
-
+ self.logger.debug("create_root called, root = %s" % self.root)
if self.root != '/':
if self.root[-1] == '/':
self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
# Here we split the path and only keep the last directory
directory = self.root.split('/')[-1]
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
else:
directory = self.root
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
iter = model.insert_before(None, None)
model.set_value(iter, 0, self.get_folder_opened_icon())
model.set_value(iter, 1, directory)
@@ -383,7 +388,7 @@
def create_new(self):
""" Create tree from scratch """
-
+ self.logger.debug("create_new called to (re)create tree")
model = self.view.get_model()
model.clear()
iter = self.create_root()
@@ -515,9 +520,44 @@
provided by gimap.
"""
def __init__(self,parent, root=None):
+ self.logger = logging.getLogger('gbacker.FileBrowserWidget.RemoteTreeFileBrowser')
+ self.logger.debug("RemoteTreeFileBrowser created with root: %s" % root)
TreeFileBrowser.__init__(self, parent, root)
+ # TODO: what if we have paths that don't start in the users home dir
+ # like trees rooted in an external HD ??
+ # In create_root the decision is made which tree to show.
+ def create_root(self):
+ """sets the root for the tree widget.
+ It will strip parts of the root to prevent large trees of single dirs.
+ """
+ model = self.view.get_model()
+ self.logger.debug("create_root called, root = %s" % self.root)
+ if self.root != '/':
+ if self.root[-1] == '/':
+ self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ # get the next subdirectories which gonna serve as the startingpoints
+ # for the RemoteTreeFileBrowser tree display
+ for directory in os.listdir(self.root):
+ iter = model.insert_before(None, None)
+ model.set_value(iter, 0, self.get_folder_opened_icon())
+ model.set_value(iter, 1, directory)
+ model.set_value(iter, 2, os.path.join(self.root, directory))
+ iter = model.insert_before(iter, None)
+# # Here we split the path and only keep the last directory
+# directory = self.root.split('/')[-1]
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
+ else:
+ directory = self.root
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
+ iter = model.insert_before(None, None)
+ model.set_value(iter, 0, self.get_folder_opened_icon())
+ model.set_value(iter, 1, directory)
+ model.set_value(iter, 2, self.root)
+ iter = model.insert_before(iter, None)
+ return iter
+
def create_popup(self):
""" Create popup menu for right click """
self.popup = gtk.Menu()
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-10 12:44:35 UTC (rev 8)
+++ GuiGtk.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -5,7 +5,7 @@
# GuiGtk.py part of gbacker
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License
-# as published by the Free Software Foundation. A copy of this license should
+# as published by the Free Software Foundation. A copy of this license should
# be included in the file GPL-3.
#
# This program is distributed in the hope that it will be useful,
@@ -76,9 +76,15 @@
SimpleGladeApp.__init__(self, glade_path, root, domain)
# get our imap related stuff
self.ac = ImapAccount(options)
+ # Start a splash like dialog because the building of the empty tree can
+ # take some time.
+ dlg = InfoDialog(_("Building the remote directory tree, please wait..."))
+ dlg.show_all()
+ while gtk.events_pending():
+ gtk.main_iteration()
+ # Worker builds a empty directory tree representing the remote directory stucture
self.worker = Worker(self.ac)
- # builds a empty directory tree representing the remote directory stucture
- self.worker.build_remote_tree()
+ dlg.destroy()
self.connected = False
# set connect and disconnect buttons sensitive
self.button_disconnect.set_sensitive(False)
@@ -118,26 +124,32 @@
# Quit from the menu is connected to the on_window1_delete_event
def on_preferences_activated(self, widget, *args):
self.logger.debug('on_preferences_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_new_directory_activated(self, widget, *args):
self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_rename_activated(self, widget, *args):
self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_delete_activated(self, widget, *args):
self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_upload_directory_activated(self, widget, *args):
self.logger.debug('on_local_upload_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_new_directory_activated(self, widget, *args):
self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_rename_activated(self, widget, *args):
@@ -146,6 +158,7 @@
def on_remote_delete_activated(self, widget, *args):
self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_download_directory_activated(self, widget, *args):
@@ -154,6 +167,7 @@
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_save_log_activated(self, widget, *args):
@@ -162,10 +176,12 @@
def on_faq_activated(self, widget, *args):
self.logger.debug('on_faq_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_about_activated(self, widget, *args):
self.logger.debug('on_about_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
######## end menu callbacks ##########
@@ -199,7 +215,7 @@
self.connected = True
# add the remote treebrowser widget
# The first part of the emptytree is stripped from the view in create_root
- root = os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:])
+ root = os.path.join(TEMPDIR, account)
self.remote_tree_widget = RemoteTreeFileBrowser(self, root)
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
@@ -268,12 +284,16 @@
return True
else:
self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
+ pbp = PbarPulser(self.pbar)
+ pbp.start()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
self._download_file(file, target)
else:
self._download_file(item, target)
+ pbp.stop()
+ self.frame_pbar.hide()
return True
###### Non-glade callbacks ############
@@ -340,10 +360,7 @@
def _download_file(self, file, target=None):
self.guilogger.write(_("Downloading %s to %s" % (file, target)))
- pp = PbarPulser(self.pbar)
- pp.start()
result = self.worker.download_file(file, dest=target)
- pp.stop()
if result:
self.guilogger.write(_("done."))
else:
@@ -457,12 +474,12 @@
class InfoDialog(WarningDialog):
def __init__(self,txt):
WarningDialog.__init__(self,parent=None,
- flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_CLOSE,
message_format='',
txt=txt)
-
+
+
class YesNoDialog(gtk.MessageDialog):
"""YesNoDialog is different as we want a respons value
dlg = YesNoDialog(txt='YesNoDialog')
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-10 12:44:35 UTC (rev 8)
+++ Worker.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -27,7 +27,7 @@
import shutil
import glob
-from gimap import ComposedMessage, Sender, ServerError
+from gimap import ComposedMessage, Sender, ServerError, NoLoginError
from Constants import *
class ReadError(Exception):
@@ -91,11 +91,13 @@
This is what happens when upload is called;
check if message already exists. (same full filepath)
- if True :
+ if True and not @sync:
remove remote message.
if True:
tell DB message is removed.
DB will remove message from dbase
+ elif True and @sync:
+ return
pass new message to DB which returns message with altered subject line.
send message
if True:
@@ -108,11 +110,12 @@
For more info about the way files are stored in gmail see the filename
'ibsig_message_format.txt' in the gbacker.
"""
- def __init__(self, account, db, treebuilder):
+ def __init__(self, account, db, treebuilder, sync=False):
self.logger = logging.getLogger('gbacker.Worker.Uploader')
self.logger.debug('Uploader created')
self.ac = account
self.db = db
+ self.sync = sync
self.remote_directory = '[Gmail]/Drafts'
self.sender = Sender(self.ac.get_server(), self.ac.imap_user, self.ac.imap_pass)
self.treebuilder = treebuilder
@@ -137,7 +140,7 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id:
+ if mesg_id and not sync:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -159,6 +162,10 @@
self.logger.debug("Trashed message(s) with mesg_id(s): %s" % mesg_id)
# update dbase and empty tree
self.db.remove_message(mesg_subject_list)
+ elif mesg_id and self.sync:
+ self.logger.debug("Found remote message: %s, leaving it alone" % mesg_id)
+ # TODO: check creationtime and size to determine if the file isn't changed
+ return
else:
self.logger.debug("No old message found")
# DB will change the subject line by adding a table id, for example 'ID8'
@@ -173,17 +180,17 @@
result = self.sender.send_message(new_msg)
if result[0] != 'OK':
self.logger.error("Failed to send the message, check the logs: %s" % result)
- self.db_new_message_send(False)
- try:
- self.treebuilder.remove_file(new_msg.get_subjectline().split('##')[1])
- except WriteError, e:
- self.logger.warning("Failed to remove file: %s" % e)
- self.logger.warning("Will continue but this shouldn't happen.")
- result = None
- self.logger.warning("Will try to send the message again, attempt %s" % tries+1)
tries += 1
+ self.logger.warning("Will try to send the message again, attempt %s" % tries)
+ tries += 1
self.logger.debug("reconnecting to server")
- # TODO: reconnect
+ self.ac.logout()
+ try:
+ self.ac.login_ssl()
+ except NoLoginError, e:
+ self.logger.critical("Can't login to server, quiting")
+ raise FinalError, e
+ self.sender = Sender(self.ac.get_server(), self.ac.imap_user, self.ac.imap_pass)
else:
self.logger.debug("Message send %s: %s" % result[:2])
self.db.new_message_send(True)
@@ -191,6 +198,16 @@
# new_msg is a ComposedMessage instance
self.treebuilder.add_file(new_msg.get_path())
break
+ else:
+ # in case we don't break from the while we failed three times to send
+ # the message and we cleanup and give up.
+ self.db_new_message_send(False)
+ try:
+ self.treebuilder.remove_file(new_msg.get_subjectline().split('##')[1])
+ except WriteError, e:
+ self.logger.warning("Failed to remove file: %s" % e)
+ self.logger.warning("Will continue but this shouldn't happen.")
+ result = None
return result
class EmptyDirectoryBuilder:
@@ -993,7 +1010,7 @@
server = ac.login_ssl()
w = Worker(ac)
#w.rebuild_dbase()
- #w.upload_directory('/home/stas/temp/test_pics')
+ w.upload_directory('/home/stas/temp/test_pics')
#w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-10 12:44:35 UTC (rev 8)
+++ gimap.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -19,6 +19,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import socket
+socket.setdefaulttimeout(10)
+
import imaplib
import time
import sys
@@ -170,7 +173,7 @@
try:
self.AC = imaplib.IMAP4_SSL(self.imap_server,self.imap_port)
self.AC.login(self.imap_user, self.imap_pass)
- except imaplib.IMAP4.error,e:
+ except (imaplib.IMAP4.error, socket.gaierror),e:
self.logger.error("imap server login raised an exception, check your ~/.imap filename")
self.logger.error("reason for the exception: %s" % e)
raise NoLoginError, e
@@ -323,7 +326,7 @@
result, message = self.AC.select(folder, readonly=1)
if result != 'OK':
raise ServerError,message
- #self.logger.debug("Searching for message(s) with pattern %s in folder %s" % (pattern, folder))
+ self.logger.debug("Searching for message(s) with pattern %s in folder %s" % (pattern, folder))
result, data = self.AC.search(None,pattern)
if result != 'OK':
raise ServerError,data
@@ -375,7 +378,6 @@
bodylist.append(line)
bodydict[key] = bodylist
return bodydict
-
def search(self,folder,pattern):
"""Search for messages in @folder which match @pattern. @folder may be None
@@ -387,7 +389,7 @@
result, message = self.AC.select(folder,readonly=1)
if result != 'OK':
raise ServerError,message
- #self.logger.debug("Searching for message(s) in %s with pattern %s" % (folder,pattern))
+ self.logger.debug("Searching for message(s) in %s with pattern %s" % (folder,pattern))
result, data = self.AC.search(None,pattern)
if result != 'OK':
raise ServerError,data
@@ -577,9 +579,14 @@
draftsbox = '[Gmail]/Drafts'
self.logger.debug("append the message to %s" % draftsbox)
emailmesg = mesg.get_message()
- result = self.server.append(draftsbox, '', '', emailmesg.as_string())
+ try:
+ result = self.server.append(draftsbox, '', '', emailmesg.as_string())
+ except self.server.abort, e:
+ self.logger.error("failed to append message: %s" % e)
+ result = ['Timeout', str(e)]
if result[0] != 'OK':
self.logger.error("Failed to send the message: %s" % result)
+ return result
else:
return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-13 06:57:07
|
Revision: 9
http://gbacker.svn.sourceforge.net/gbacker/?rev=9&view=rev
Author: stas_zytkiewicz
Date: 2009-12-13 06:56:59 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
More work done to make worker more stable and
added the ability to reconnect in case of network trouble.
Also a socket timeout was added.
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Worker.py
gimap.py
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-10 12:44:35 UTC (rev 8)
+++ FileBrowserWidget.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -28,6 +28,7 @@
import os
import gtk
import gobject
+import logging
class TreeFileBrowser(gobject.GObject):
""" A widget that implements a tree-like file browser, like the
@@ -52,7 +53,8 @@
""" root is where we want the tree initialized """
self.parent = parent
gobject.GObject.__init__(self)
-
+ self.logger = logging.getLogger('gbacker.FileBrowserWidget.TreeFileBrowser')
+ self.logger.debug("TreeFileBrowser created with root: %s" % root)
self.show_hidden = False
# set to false to show all files
self.show_only_dirs = False
@@ -60,10 +62,11 @@
self.sort_dir_files = True
self.show_rules_hint = True
self.multiple_selection = True
-
+ self.logger.debug("testing is dir: %s" % root)
if root != None and os.path.isdir(root):
self.root = root
else:
+ self.logger.debug("Can't find %s, set root to '/'" % root)
self.root = '/'
self.view, self.scrolled = self.make_view()
@@ -366,14 +369,16 @@
It will strip parts of the root to prevent large trees of single dirs.
"""
model = self.view.get_model()
-
+ self.logger.debug("create_root called, root = %s" % self.root)
if self.root != '/':
if self.root[-1] == '/':
self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
# Here we split the path and only keep the last directory
directory = self.root.split('/')[-1]
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
else:
directory = self.root
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
iter = model.insert_before(None, None)
model.set_value(iter, 0, self.get_folder_opened_icon())
model.set_value(iter, 1, directory)
@@ -383,7 +388,7 @@
def create_new(self):
""" Create tree from scratch """
-
+ self.logger.debug("create_new called to (re)create tree")
model = self.view.get_model()
model.clear()
iter = self.create_root()
@@ -515,9 +520,44 @@
provided by gimap.
"""
def __init__(self,parent, root=None):
+ self.logger = logging.getLogger('gbacker.FileBrowserWidget.RemoteTreeFileBrowser')
+ self.logger.debug("RemoteTreeFileBrowser created with root: %s" % root)
TreeFileBrowser.__init__(self, parent, root)
+ # TODO: what if we have paths that don't start in the users home dir
+ # like trees rooted in an external HD ??
+ # In create_root the decision is made which tree to show.
+ def create_root(self):
+ """sets the root for the tree widget.
+ It will strip parts of the root to prevent large trees of single dirs.
+ """
+ model = self.view.get_model()
+ self.logger.debug("create_root called, root = %s" % self.root)
+ if self.root != '/':
+ if self.root[-1] == '/':
+ self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ # get the next subdirectories which gonna serve as the startingpoints
+ # for the RemoteTreeFileBrowser tree display
+ for directory in os.listdir(self.root):
+ iter = model.insert_before(None, None)
+ model.set_value(iter, 0, self.get_folder_opened_icon())
+ model.set_value(iter, 1, directory)
+ model.set_value(iter, 2, os.path.join(self.root, directory))
+ iter = model.insert_before(iter, None)
+# # Here we split the path and only keep the last directory
+# directory = self.root.split('/')[-1]
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
+ else:
+ directory = self.root
+ self.logger.debug("create_root sets iter 1 to %s" % directory)
+ iter = model.insert_before(None, None)
+ model.set_value(iter, 0, self.get_folder_opened_icon())
+ model.set_value(iter, 1, directory)
+ model.set_value(iter, 2, self.root)
+ iter = model.insert_before(iter, None)
+ return iter
+
def create_popup(self):
""" Create popup menu for right click """
self.popup = gtk.Menu()
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-10 12:44:35 UTC (rev 8)
+++ GuiGtk.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -5,7 +5,7 @@
# GuiGtk.py part of gbacker
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License
-# as published by the Free Software Foundation. A copy of this license should
+# as published by the Free Software Foundation. A copy of this license should
# be included in the file GPL-3.
#
# This program is distributed in the hope that it will be useful,
@@ -76,9 +76,15 @@
SimpleGladeApp.__init__(self, glade_path, root, domain)
# get our imap related stuff
self.ac = ImapAccount(options)
+ # Start a splash like dialog because the building of the empty tree can
+ # take some time.
+ dlg = InfoDialog(_("Building the remote directory tree, please wait..."))
+ dlg.show_all()
+ while gtk.events_pending():
+ gtk.main_iteration()
+ # Worker builds a empty directory tree representing the remote directory stucture
self.worker = Worker(self.ac)
- # builds a empty directory tree representing the remote directory stucture
- self.worker.build_remote_tree()
+ dlg.destroy()
self.connected = False
# set connect and disconnect buttons sensitive
self.button_disconnect.set_sensitive(False)
@@ -118,26 +124,32 @@
# Quit from the menu is connected to the on_window1_delete_event
def on_preferences_activated(self, widget, *args):
self.logger.debug('on_preferences_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_new_directory_activated(self, widget, *args):
self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_rename_activated(self, widget, *args):
self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_delete_activated(self, widget, *args):
self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_local_upload_directory_activated(self, widget, *args):
self.logger.debug('on_local_upload_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_new_directory_activated(self, widget, *args):
self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_rename_activated(self, widget, *args):
@@ -146,6 +158,7 @@
def on_remote_delete_activated(self, widget, *args):
self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_remote_download_directory_activated(self, widget, *args):
@@ -154,6 +167,7 @@
def on_clear_log_activated(self, widget, *args):
self.logger.debug('on_clear_log_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_save_log_activated(self, widget, *args):
@@ -162,10 +176,12 @@
def on_faq_activated(self, widget, *args):
self.logger.debug('on_faq_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
def on_about_activated(self, widget, *args):
self.logger.debug('on_about_activated called with self.%s' % widget.get_name())
+ InfoDialog("Not yet implemented")
return True
######## end menu callbacks ##########
@@ -199,7 +215,7 @@
self.connected = True
# add the remote treebrowser widget
# The first part of the emptytree is stripped from the view in create_root
- root = os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:])
+ root = os.path.join(TEMPDIR, account)
self.remote_tree_widget = RemoteTreeFileBrowser(self, root)
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
@@ -268,12 +284,16 @@
return True
else:
self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
+ pbp = PbarPulser(self.pbar)
+ pbp.start()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
self._download_file(file, target)
else:
self._download_file(item, target)
+ pbp.stop()
+ self.frame_pbar.hide()
return True
###### Non-glade callbacks ############
@@ -340,10 +360,7 @@
def _download_file(self, file, target=None):
self.guilogger.write(_("Downloading %s to %s" % (file, target)))
- pp = PbarPulser(self.pbar)
- pp.start()
result = self.worker.download_file(file, dest=target)
- pp.stop()
if result:
self.guilogger.write(_("done."))
else:
@@ -457,12 +474,12 @@
class InfoDialog(WarningDialog):
def __init__(self,txt):
WarningDialog.__init__(self,parent=None,
- flags=gtk.DIALOG_MODAL,
type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_CLOSE,
message_format='',
txt=txt)
-
+
+
class YesNoDialog(gtk.MessageDialog):
"""YesNoDialog is different as we want a respons value
dlg = YesNoDialog(txt='YesNoDialog')
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-10 12:44:35 UTC (rev 8)
+++ Worker.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -27,7 +27,7 @@
import shutil
import glob
-from gimap import ComposedMessage, Sender, ServerError
+from gimap import ComposedMessage, Sender, ServerError, NoLoginError
from Constants import *
class ReadError(Exception):
@@ -91,11 +91,13 @@
This is what happens when upload is called;
check if message already exists. (same full filepath)
- if True :
+ if True and not @sync:
remove remote message.
if True:
tell DB message is removed.
DB will remove message from dbase
+ elif True and @sync:
+ return
pass new message to DB which returns message with altered subject line.
send message
if True:
@@ -108,11 +110,12 @@
For more info about the way files are stored in gmail see the filename
'ibsig_message_format.txt' in the gbacker.
"""
- def __init__(self, account, db, treebuilder):
+ def __init__(self, account, db, treebuilder, sync=False):
self.logger = logging.getLogger('gbacker.Worker.Uploader')
self.logger.debug('Uploader created')
self.ac = account
self.db = db
+ self.sync = sync
self.remote_directory = '[Gmail]/Drafts'
self.sender = Sender(self.ac.get_server(), self.ac.imap_user, self.ac.imap_pass)
self.treebuilder = treebuilder
@@ -137,7 +140,7 @@
mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
- if mesg_id:
+ if mesg_id and not sync:
self.logger.debug("Found remote message: %s" % mesg_id)
try:
messages = self.ac.get_message(mesg_id, box='[Gmail]/Drafts')
@@ -159,6 +162,10 @@
self.logger.debug("Trashed message(s) with mesg_id(s): %s" % mesg_id)
# update dbase and empty tree
self.db.remove_message(mesg_subject_list)
+ elif mesg_id and self.sync:
+ self.logger.debug("Found remote message: %s, leaving it alone" % mesg_id)
+ # TODO: check creationtime and size to determine if the file isn't changed
+ return
else:
self.logger.debug("No old message found")
# DB will change the subject line by adding a table id, for example 'ID8'
@@ -173,17 +180,17 @@
result = self.sender.send_message(new_msg)
if result[0] != 'OK':
self.logger.error("Failed to send the message, check the logs: %s" % result)
- self.db_new_message_send(False)
- try:
- self.treebuilder.remove_file(new_msg.get_subjectline().split('##')[1])
- except WriteError, e:
- self.logger.warning("Failed to remove file: %s" % e)
- self.logger.warning("Will continue but this shouldn't happen.")
- result = None
- self.logger.warning("Will try to send the message again, attempt %s" % tries+1)
tries += 1
+ self.logger.warning("Will try to send the message again, attempt %s" % tries)
+ tries += 1
self.logger.debug("reconnecting to server")
- # TODO: reconnect
+ self.ac.logout()
+ try:
+ self.ac.login_ssl()
+ except NoLoginError, e:
+ self.logger.critical("Can't login to server, quiting")
+ raise FinalError, e
+ self.sender = Sender(self.ac.get_server(), self.ac.imap_user, self.ac.imap_pass)
else:
self.logger.debug("Message send %s: %s" % result[:2])
self.db.new_message_send(True)
@@ -191,6 +198,16 @@
# new_msg is a ComposedMessage instance
self.treebuilder.add_file(new_msg.get_path())
break
+ else:
+ # in case we don't break from the while we failed three times to send
+ # the message and we cleanup and give up.
+ self.db_new_message_send(False)
+ try:
+ self.treebuilder.remove_file(new_msg.get_subjectline().split('##')[1])
+ except WriteError, e:
+ self.logger.warning("Failed to remove file: %s" % e)
+ self.logger.warning("Will continue but this shouldn't happen.")
+ result = None
return result
class EmptyDirectoryBuilder:
@@ -993,7 +1010,7 @@
server = ac.login_ssl()
w = Worker(ac)
#w.rebuild_dbase()
- #w.upload_directory('/home/stas/temp/test_pics')
+ w.upload_directory('/home/stas/temp/test_pics')
#w.upload_directory('/home/stas/SVN-WORK/gbacker/TestDir')
#r = w.get_send_report()
#for k, v in r.items():
Modified: gimap.py
===================================================================
--- gimap.py 2009-12-10 12:44:35 UTC (rev 8)
+++ gimap.py 2009-12-13 06:56:59 UTC (rev 9)
@@ -19,6 +19,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import socket
+socket.setdefaulttimeout(10)
+
import imaplib
import time
import sys
@@ -170,7 +173,7 @@
try:
self.AC = imaplib.IMAP4_SSL(self.imap_server,self.imap_port)
self.AC.login(self.imap_user, self.imap_pass)
- except imaplib.IMAP4.error,e:
+ except (imaplib.IMAP4.error, socket.gaierror),e:
self.logger.error("imap server login raised an exception, check your ~/.imap filename")
self.logger.error("reason for the exception: %s" % e)
raise NoLoginError, e
@@ -323,7 +326,7 @@
result, message = self.AC.select(folder, readonly=1)
if result != 'OK':
raise ServerError,message
- #self.logger.debug("Searching for message(s) with pattern %s in folder %s" % (pattern, folder))
+ self.logger.debug("Searching for message(s) with pattern %s in folder %s" % (pattern, folder))
result, data = self.AC.search(None,pattern)
if result != 'OK':
raise ServerError,data
@@ -375,7 +378,6 @@
bodylist.append(line)
bodydict[key] = bodylist
return bodydict
-
def search(self,folder,pattern):
"""Search for messages in @folder which match @pattern. @folder may be None
@@ -387,7 +389,7 @@
result, message = self.AC.select(folder,readonly=1)
if result != 'OK':
raise ServerError,message
- #self.logger.debug("Searching for message(s) in %s with pattern %s" % (folder,pattern))
+ self.logger.debug("Searching for message(s) in %s with pattern %s" % (folder,pattern))
result, data = self.AC.search(None,pattern)
if result != 'OK':
raise ServerError,data
@@ -577,9 +579,14 @@
draftsbox = '[Gmail]/Drafts'
self.logger.debug("append the message to %s" % draftsbox)
emailmesg = mesg.get_message()
- result = self.server.append(draftsbox, '', '', emailmesg.as_string())
+ try:
+ result = self.server.append(draftsbox, '', '', emailmesg.as_string())
+ except self.server.abort, e:
+ self.logger.error("failed to append message: %s" % e)
+ result = ['Timeout', str(e)]
if result[0] != 'OK':
self.logger.error("Failed to send the message: %s" % result)
+ return result
else:
return result
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-10 12:44:47
|
Revision: 8
http://gbacker.svn.sourceforge.net/gbacker/?rev=8&view=rev
Author: stas_zytkiewicz
Date: 2009-12-10 12:44:35 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
more work
Modified Paths:
--------------
Worker.py
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-03 14:21:14 UTC (rev 7)
+++ Worker.py 2009-12-10 12:44:35 UTC (rev 8)
@@ -134,7 +134,7 @@
# check if we have a message for this file.
# This can be time consuming in large accounts, don't know if we can
# avoid it but we *must* make sure we only have one message per file.
- mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT %s)' % msg.msg['Subject'])
+ mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
if mesg_id:
@@ -662,6 +662,7 @@
self.server = self.ac.get_server()
self.db = DB(account=self.ac.imap_user)
self.sendreport = {}
+ self.build_remote_tree()
atexit.register(self.stop)
####### some shortcut methods for the GUI
@@ -708,7 +709,7 @@
def rebuild_dbase(self):
"""Will rebuild the complete dbase in case of a dbase corruption.
- The empty dirtree will also be rebuild as it shoudl be in sync with the db.
+ The empty dirtree will also be rebuild as it shoud be in sync with the db.
It will download all the data needed to rebuild the message table.
It won't download the complete messages.
Returns None on success and a tuple with the error message and text on
@@ -727,7 +728,7 @@
except FinalError, e:
self.logger.critical("Failed to rebuild dbase table: %s" % e)
raise FinalError, e
- #self.build_remote_tree()
+ self.build_remote_tree()
self.logger.warning("Done rebuilding database")
def delete_remote_dir(self, directory):
@@ -999,7 +1000,7 @@
# print k, v
#w.download_directory('/home/stas/SVN-WORK/gbacker/TestDir', '/tmp')
- w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
+ #w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
#w.build_remote_tree()
#w.delete_remote_dir(os.path.abspath('TestDir'))
@@ -1011,5 +1012,6 @@
# rr = RemoteDirectoryReader(ac, '/home/stas/SVN-WORK/gbacker')
# files = rr.get_filenames_from_dir()
# print files
+ raw_input("hit any key to stop")
w.stop()
ac.logout()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-10 12:44:47
|
Revision: 8
http://gbacker.svn.sourceforge.net/gbacker/?rev=8&view=rev
Author: stas_zytkiewicz
Date: 2009-12-10 12:44:35 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
more work
Modified Paths:
--------------
Worker.py
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-03 14:21:14 UTC (rev 7)
+++ Worker.py 2009-12-10 12:44:35 UTC (rev 8)
@@ -134,7 +134,7 @@
# check if we have a message for this file.
# This can be time consuming in large accounts, don't know if we can
# avoid it but we *must* make sure we only have one message per file.
- mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT %s)' % msg.msg['Subject'])
+ mesg_id = self.ac.get_id(self.remote_directory,'(SUBJECT "%s")' % msg.msg['Subject'])
status = None
mesg_subject_list = []
if mesg_id:
@@ -662,6 +662,7 @@
self.server = self.ac.get_server()
self.db = DB(account=self.ac.imap_user)
self.sendreport = {}
+ self.build_remote_tree()
atexit.register(self.stop)
####### some shortcut methods for the GUI
@@ -708,7 +709,7 @@
def rebuild_dbase(self):
"""Will rebuild the complete dbase in case of a dbase corruption.
- The empty dirtree will also be rebuild as it shoudl be in sync with the db.
+ The empty dirtree will also be rebuild as it shoud be in sync with the db.
It will download all the data needed to rebuild the message table.
It won't download the complete messages.
Returns None on success and a tuple with the error message and text on
@@ -727,7 +728,7 @@
except FinalError, e:
self.logger.critical("Failed to rebuild dbase table: %s" % e)
raise FinalError, e
- #self.build_remote_tree()
+ self.build_remote_tree()
self.logger.warning("Done rebuilding database")
def delete_remote_dir(self, directory):
@@ -999,7 +1000,7 @@
# print k, v
#w.download_directory('/home/stas/SVN-WORK/gbacker/TestDir', '/tmp')
- w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
+ #w.download_file('/home/stas/SVN-WORK/gbacker/TestDir/test1.txt', '/tmp')
#w.build_remote_tree()
#w.delete_remote_dir(os.path.abspath('TestDir'))
@@ -1011,5 +1012,6 @@
# rr = RemoteDirectoryReader(ac, '/home/stas/SVN-WORK/gbacker')
# files = rr.get_filenames_from_dir()
# print files
+ raw_input("hit any key to stop")
w.stop()
ac.logout()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 14:21:24
|
Revision: 7
http://gbacker.svn.sourceforge.net/gbacker/?rev=7&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 14:21:14 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
removed double text file
Removed Paths:
-------------
sf.txt
Deleted: sf.txt
===================================================================
--- sf.txt 2009-12-03 14:17:59 UTC (rev 6)
+++ sf.txt 2009-12-03 14:21:14 UTC (rev 7)
@@ -1,19 +0,0 @@
-Gbacker is a program to backup and restore files using a Gmail mail account.
-It uses the Gmail account as a remote file server.
-In contrast to other similar solutions like gdrive, gmailsync etc
-gbacker is fully compliant with the Gmail 'terms of use' and your not limited
-to a maximum of 500 uploads per 24 hours.
-With gbacker you can fully use the online storage space offered by Gmail.
-
-Gbacker is written in Python and uses sqlite3 for the database and GTK
-for the GUI.
-It uses the imap mail protocol and a sqlite database to mimic a remote directorytree.
-Gbacker can be used as a commandline application to backup and restore
-directories. It can also be used as a cron job to sync the backup.
-
-In addition to the commandline program there's also a GUI provided which
-acts as a two windowed file browser.
-
-Gbacker is designed to be as robust as possible even when the network connection
-is unstable. Great care is taken to ensure correct backups.
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 14:21:22
|
Revision: 7
http://gbacker.svn.sourceforge.net/gbacker/?rev=7&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 14:21:14 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
removed double text file
Removed Paths:
-------------
sf.txt
Deleted: sf.txt
===================================================================
--- sf.txt 2009-12-03 14:17:59 UTC (rev 6)
+++ sf.txt 2009-12-03 14:21:14 UTC (rev 7)
@@ -1,19 +0,0 @@
-Gbacker is a program to backup and restore files using a Gmail mail account.
-It uses the Gmail account as a remote file server.
-In contrast to other similar solutions like gdrive, gmailsync etc
-gbacker is fully compliant with the Gmail 'terms of use' and your not limited
-to a maximum of 500 uploads per 24 hours.
-With gbacker you can fully use the online storage space offered by Gmail.
-
-Gbacker is written in Python and uses sqlite3 for the database and GTK
-for the GUI.
-It uses the imap mail protocol and a sqlite database to mimic a remote directorytree.
-Gbacker can be used as a commandline application to backup and restore
-directories. It can also be used as a cron job to sync the backup.
-
-In addition to the commandline program there's also a GUI provided which
-acts as a two windowed file browser.
-
-Gbacker is designed to be as robust as possible even when the network connection
-is unstable. Great care is taken to ensure correct backups.
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 14:18:11
|
Revision: 6
http://gbacker.svn.sourceforge.net/gbacker/?rev=6&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 14:17:59 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
Renaming text file and added extra cmd line options
Modified Paths:
--------------
GuiGtk.py
Optparser.py
Worker.py
sf.txt
Added Paths:
-----------
doc/info.txt
Removed Paths:
-------------
doc/fdl.txt
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-03 13:14:23 UTC (rev 5)
+++ GuiGtk.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -77,6 +77,8 @@
# get our imap related stuff
self.ac = ImapAccount(options)
self.worker = Worker(self.ac)
+ # builds a empty directory tree representing the remote directory stucture
+ self.worker.build_remote_tree()
self.connected = False
# set connect and disconnect buttons sensitive
self.button_disconnect.set_sensitive(False)
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-03 13:14:23 UTC (rev 5)
+++ Optparser.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -28,7 +28,7 @@
usage = "usage: %prog [options]"
OptionParser.__init__(self,usage=usage,version=version)
# set some reasonable defaults
- self.set_defaults(loglevel="debug",\
+ self.set_defaults(loglevel="warning",\
imap_port="993",\
imap_server="imap.gmail.com")
# add possible options to the parser
@@ -56,9 +56,9 @@
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
dest="destination")
- self.add_option("-a", "--rebuilddb",
- help="Rebuilds the database ",
- dest="destination")
+ self.add_option("--rebuilddb",action="store_true",
+ help="Rebuilds the database in case it's corrupted. It will download all the subject lines from the Gmail messages in the account to rebuild the database table. Corruption of the database occurs when the program would crash or when you have a very flaky network connection.",
+ dest="rebuilddb")
(self.options, self.args) = self.parse_args()
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-03 13:14:23 UTC (rev 5)
+++ Worker.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -274,7 +274,6 @@
else:
self.logger.debug("Written: %s" % filepath)
-
def remove_directory(self, path):
self.logger.debug("remove_directory called with:%s" % path)
destdir, name = self._get_root(path)
@@ -663,7 +662,6 @@
self.server = self.ac.get_server()
self.db = DB(account=self.ac.imap_user)
self.sendreport = {}
- self.build_remote_tree()
atexit.register(self.stop)
####### some shortcut methods for the GUI
@@ -715,19 +713,22 @@
It won't download the complete messages.
Returns None on success and a tuple with the error message and text on
failure."""
- #self.logger.debug("get email ids")
+ self.logger.warning("Rebuilding database, don't interrupt this.")
+ self.logger.debug("get email ids")
mesg_ids = self.ac.get_id('', 'ALL')
- #self.logger.debug("found ids: %s" % mesg_ids)
- #self.logger.debug("get message subjects")
+ self.logger.warning("found ids: %s" % mesg_ids)
+ self.logger.warning("get message subjects")
subjectdict = self.ac.fetch_subject(mesg_ids)
- self.logger.debug("get message body text")
+ self.logger.warning("get message body text, this can take some time on larger backups.")
bodydict = self.ac.fetch_body(mesg_ids)
+ self.logger.warning("done downloading message bodies.")
try:
self.db.rebuild_dbase(subjectdict, bodydict)
except FinalError, e:
self.logger.critical("Failed to rebuild dbase table: %s" % e)
raise FinalError, e
- self.build_remote_tree()
+ #self.build_remote_tree()
+ self.logger.warning("Done rebuilding database")
def delete_remote_dir(self, directory):
"""Delete the remote directory.
Deleted: doc/fdl.txt
===================================================================
--- doc/fdl.txt 2009-12-03 13:14:23 UTC (rev 5)
+++ doc/fdl.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -1,451 +0,0 @@
-
- GNU Free Documentation License
- Version 1.3, 3 November 2008
-
-
- Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
- <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-0. PREAMBLE
-
-The purpose of this License is to make a manual, textbook, or other
-functional and useful document "free" in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
-This License is a kind of "copyleft", which means that derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
-We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
-
-1. APPLICABILITY AND DEFINITIONS
-
-This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The "Document", below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as "you". You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
-A "Modified Version" of the Document means any work containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
-A "Secondary Section" is a named appendix or a front-matter section of
-the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
-The "Invariant Sections" are certain Secondary Sections whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
-The "Cover Texts" are certain short passages of text that are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
-A "Transparent" copy of the Document means a machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not "Transparent" is called "Opaque".
-
-Examples of suitable formats for Transparent copies include plain
-ASCII without markup, Texinfo input format, LaTeX input format, SGML
-or XML using a publicly available DTD, and standard-conforming simple
-HTML, PostScript or PDF designed for human modification. Examples of
-transparent image formats include PNG, XCF and JPG. Opaque formats
-include proprietary formats that can be read and edited only by
-proprietary word processors, SGML or XML for which the DTD and/or
-processing tools are not generally available, and the
-machine-generated HTML, PostScript or PDF produced by some word
-processors for output purposes only.
-
-The "Title Page" means, for a printed book, the title page itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, "Title Page" means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
-The "publisher" means any person or entity that distributes copies of
-the Document to the public.
-
-A section "Entitled XYZ" means a named subunit of the Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as "Acknowledgements",
-"Dedications", "Endorsements", or "History".) To "Preserve the Title"
-of such a section when you modify the Document means that it remains a
-section "Entitled XYZ" according to this definition.
-
-The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
-2. VERBATIM COPYING
-
-You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no
-other conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
-You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
-
-3. COPYING IN QUANTITY
-
-If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
-If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
-If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
-It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to
-give them a chance to provide you with an updated version of the
-Document.
-
-
-4. MODIFICATIONS
-
-You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
-A. Use in the Title Page (and on the covers, if any) a title distinct
- from that of the Document, and from those of previous versions
- (which should, if there were any, be listed in the History section
- of the Document). You may use the same title as a previous version
- if the original publisher of that version gives permission.
-B. List on the Title Page, as authors, one or more persons or entities
- responsible for authorship of the modifications in the Modified
- Version, together with at least five of the principal authors of the
- Document (all of its principal authors, if it has fewer than five),
- unless they release you from this requirement.
-C. State on the Title page the name of the publisher of the
- Modified Version, as the publisher.
-D. Preserve all the copyright notices of the Document.
-E. Add an appropriate copyright notice for your modifications
- adjacent to the other copyright notices.
-F. Include, immediately after the copyright notices, a license notice
- giving the public permission to use the Modified Version under the
- terms of this License, in the form shown in the Addendum below.
-G. Preserve in that license notice the full lists of Invariant Sections
- and required Cover Texts given in the Document's license notice.
-H. Include an unaltered copy of this License.
-I. Preserve the section Entitled "History", Preserve its Title, and add
- to it an item stating at least the title, year, new authors, and
- publisher of the Modified Version as given on the Title Page. If
- there is no section Entitled "History" in the Document, create one
- stating the title, year, authors, and publisher of the Document as
- given on its Title Page, then add an item describing the Modified
- Version as stated in the previous sentence.
-J. Preserve the network location, if any, given in the Document for
- public access to a Transparent copy of the Document, and likewise
- the network locations given in the Document for previous versions
- it was based on. These may be placed in the "History" section.
- You may omit a network location for a work that was published at
- least four years before the Document itself, or if the original
- publisher of the version it refers to gives permission.
-K. For any section Entitled "Acknowledgements" or "Dedications",
- Preserve the Title of the section, and preserve in the section all
- the substance and tone of each of the contributor acknowledgements
- and/or dedications given therein.
-L. Preserve all the Invariant Sections of the Document,
- unaltered in their text and in their titles. Section numbers
- or the equivalent are not considered part of the section titles.
-M. Delete any section Entitled "Endorsements". Such a section
- may not be included in the Modified Version.
-N. Do not retitle any existing section to be Entitled "Endorsements"
- or to conflict in title with any Invariant Section.
-O. Preserve any Warranty Disclaimers.
-
-If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
-You may add a section Entitled "Endorsements", provided it contains
-nothing but endorsements of your Modified Version by various
-parties--for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
-You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
-The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
-
-5. COMBINING DOCUMENTS
-
-You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
-The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
-In the combination, you must combine any sections Entitled "History"
-in the various original documents, forming one section Entitled
-"History"; likewise combine any sections Entitled "Acknowledgements",
-and any sections Entitled "Dedications". You must delete all sections
-Entitled "Endorsements".
-
-
-6. COLLECTIONS OF DOCUMENTS
-
-You may make a collection consisting of the Document and other
-documents released under this License, and replace the individual
-copies of this License in the various documents with a single copy
-that is included in the collection, provided that you follow the rules
-of this License for verbatim copying of each of the documents in all
-other respects.
-
-You may extract a single document from such a collection, and
-distribute it individually under this License, provided you insert a
-copy of this License into the extracted document, and follow this
-License in all other respects regarding verbatim copying of that
-document.
-
-
-7. AGGREGATION WITH INDEPENDENT WORKS
-
-A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an "aggregate" if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included in an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
-If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
-
-8. TRANSLATION
-
-Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warranty Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
-If a section in the Document is Entitled "Acknowledgements",
-"Dedications", or "History", the requirement (section 4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
-
-9. TERMINATION
-
-You may not copy, modify, sublicense, or distribute the Document
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense, or distribute it is void, and
-will automatically terminate your rights under this License.
-
-However, if you cease all violation of this License, then your license
-from a particular copyright holder is reinstated (a) provisionally,
-unless and until the copyright holder explicitly and finally
-terminates your license, and (b) permanently, if the copyright holder
-fails to notify you of the violation by some reasonable means prior to
-60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, receipt of a copy of some or all of the same material does
-not give you any rights to use it.
-
-
-10. FUTURE REVISIONS OF THIS LICENSE
-
-The Free Software Foundation may publish new, revised versions of the
-GNU Free Documentation License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in
-detail to address new problems or concerns. See
-http://www.gnu.org/copyleft/.
-
-Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License "or any later version" applies to it, you have the option of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation. If the Document
-specifies that a proxy can decide which future versions of this
-License can be used, that proxy's public statement of acceptance of a
-version permanently authorizes you to choose that version for the
-Document.
-
-11. RELICENSING
-
-"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
-World Wide Web server that publishes copyrightable works and also
-provides prominent facilities for anybody to edit those works. A
-public wiki that anybody can edit is an example of such a server. A
-"Massive Multiauthor Collaboration" (or "MMC") contained in the site
-means any set of copyrightable works thus published on the MMC site.
-
-"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
-license published by Creative Commons Corporation, a not-for-profit
-corporation with a principal place of business in San Francisco,
-California, as well as future copyleft versions of that license
-published by that same organization.
-
-"Incorporate" means to publish or republish a Document, in whole or in
-part, as part of another Document.
-
-An MMC is "eligible for relicensing" if it is licensed under this
-License, and if all works that were first published under this License
-somewhere other than this MMC, and subsequently incorporated in whole or
-in part into the MMC, (1) had no cover texts or invariant sections, and
-(2) were thus incorporated prior to November 1, 2008.
-
-The operator of an MMC Site may republish an MMC contained in the site
-under CC-BY-SA on the same site at any time before August 1, 2009,
-provided the MMC is eligible for relicensing.
-
-
-ADDENDUM: How to use this License for your documents
-
-To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
- Copyright (c) YEAR YOUR NAME.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
- A copy of the license is included in the section entitled "GNU
- Free Documentation License".
-
-If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the "with...Texts." line with this:
-
- with the Invariant Sections being LIST THEIR TITLES, with the
- Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
-
-If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
-If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
Added: doc/info.txt
===================================================================
--- doc/info.txt (rev 0)
+++ doc/info.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -0,0 +1,19 @@
+Gbacker is a program to backup and restore files using a Gmail mail account.
+It uses the Gmail account as a remote file server.
+In contrast to other similar solutions like gdrive, gmailsync etc
+gbacker is fully compliant with the Gmail 'terms of use' and your not limited
+to a maximum of 500 uploads per 24 hours.
+With gbacker you can fully use the online storage space offered by Gmail.
+
+Gbacker is written in Python and uses sqlite3 for the database and GTK
+for the GUI.
+It uses the imap mail protocol and a sqlite database to mimic a remote directorytree.
+Gbacker can be used as a commandline application to backup and restore
+directories. It can also be used as a cron job to sync the backup.
+
+In addition to the commandline program there's also a GUI provided which
+acts as a two windowed file browser.
+
+Gbacker is designed to be as robust as possible even when the network connection
+is unstable. Great care is taken to ensure correct backups.
+
Modified: sf.txt
===================================================================
--- sf.txt 2009-12-03 13:14:23 UTC (rev 5)
+++ sf.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -1,7 +1,7 @@
Gbacker is a program to backup and restore files using a Gmail mail account.
It uses the Gmail account as a remote file server.
In contrast to other similar solutions like gdrive, gmailsync etc
-gbacker is fully compliant with the Gmail terms of use and your not limited
+gbacker is fully compliant with the Gmail 'terms of use' and your not limited
to a maximum of 500 uploads per 24 hours.
With gbacker you can fully use the online storage space offered by Gmail.
@@ -14,6 +14,6 @@
In addition to the commandline program there's also a GUI provided which
acts as a two windowed file browser.
-Gbacker is designed to be robust as possible even when the network connection
+Gbacker is designed to be as robust as possible even when the network connection
is unstable. Great care is taken to ensure correct backups.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 14:18:09
|
Revision: 6
http://gbacker.svn.sourceforge.net/gbacker/?rev=6&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 14:17:59 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
Renaming text file and added extra cmd line options
Modified Paths:
--------------
GuiGtk.py
Optparser.py
Worker.py
sf.txt
Added Paths:
-----------
doc/info.txt
Removed Paths:
-------------
doc/fdl.txt
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-03 13:14:23 UTC (rev 5)
+++ GuiGtk.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -77,6 +77,8 @@
# get our imap related stuff
self.ac = ImapAccount(options)
self.worker = Worker(self.ac)
+ # builds a empty directory tree representing the remote directory stucture
+ self.worker.build_remote_tree()
self.connected = False
# set connect and disconnect buttons sensitive
self.button_disconnect.set_sensitive(False)
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-03 13:14:23 UTC (rev 5)
+++ Optparser.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -28,7 +28,7 @@
usage = "usage: %prog [options]"
OptionParser.__init__(self,usage=usage,version=version)
# set some reasonable defaults
- self.set_defaults(loglevel="debug",\
+ self.set_defaults(loglevel="warning",\
imap_port="993",\
imap_server="imap.gmail.com")
# add possible options to the parser
@@ -56,9 +56,9 @@
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
dest="destination")
- self.add_option("-a", "--rebuilddb",
- help="Rebuilds the database ",
- dest="destination")
+ self.add_option("--rebuilddb",action="store_true",
+ help="Rebuilds the database in case it's corrupted. It will download all the subject lines from the Gmail messages in the account to rebuild the database table. Corruption of the database occurs when the program would crash or when you have a very flaky network connection.",
+ dest="rebuilddb")
(self.options, self.args) = self.parse_args()
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-03 13:14:23 UTC (rev 5)
+++ Worker.py 2009-12-03 14:17:59 UTC (rev 6)
@@ -274,7 +274,6 @@
else:
self.logger.debug("Written: %s" % filepath)
-
def remove_directory(self, path):
self.logger.debug("remove_directory called with:%s" % path)
destdir, name = self._get_root(path)
@@ -663,7 +662,6 @@
self.server = self.ac.get_server()
self.db = DB(account=self.ac.imap_user)
self.sendreport = {}
- self.build_remote_tree()
atexit.register(self.stop)
####### some shortcut methods for the GUI
@@ -715,19 +713,22 @@
It won't download the complete messages.
Returns None on success and a tuple with the error message and text on
failure."""
- #self.logger.debug("get email ids")
+ self.logger.warning("Rebuilding database, don't interrupt this.")
+ self.logger.debug("get email ids")
mesg_ids = self.ac.get_id('', 'ALL')
- #self.logger.debug("found ids: %s" % mesg_ids)
- #self.logger.debug("get message subjects")
+ self.logger.warning("found ids: %s" % mesg_ids)
+ self.logger.warning("get message subjects")
subjectdict = self.ac.fetch_subject(mesg_ids)
- self.logger.debug("get message body text")
+ self.logger.warning("get message body text, this can take some time on larger backups.")
bodydict = self.ac.fetch_body(mesg_ids)
+ self.logger.warning("done downloading message bodies.")
try:
self.db.rebuild_dbase(subjectdict, bodydict)
except FinalError, e:
self.logger.critical("Failed to rebuild dbase table: %s" % e)
raise FinalError, e
- self.build_remote_tree()
+ #self.build_remote_tree()
+ self.logger.warning("Done rebuilding database")
def delete_remote_dir(self, directory):
"""Delete the remote directory.
Deleted: doc/fdl.txt
===================================================================
--- doc/fdl.txt 2009-12-03 13:14:23 UTC (rev 5)
+++ doc/fdl.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -1,451 +0,0 @@
-
- GNU Free Documentation License
- Version 1.3, 3 November 2008
-
-
- Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
- <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-0. PREAMBLE
-
-The purpose of this License is to make a manual, textbook, or other
-functional and useful document "free" in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
-This License is a kind of "copyleft", which means that derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
-We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
-
-1. APPLICABILITY AND DEFINITIONS
-
-This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The "Document", below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as "you". You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
-A "Modified Version" of the Document means any work containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
-A "Secondary Section" is a named appendix or a front-matter section of
-the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
-The "Invariant Sections" are certain Secondary Sections whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
-The "Cover Texts" are certain short passages of text that are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
-A "Transparent" copy of the Document means a machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not "Transparent" is called "Opaque".
-
-Examples of suitable formats for Transparent copies include plain
-ASCII without markup, Texinfo input format, LaTeX input format, SGML
-or XML using a publicly available DTD, and standard-conforming simple
-HTML, PostScript or PDF designed for human modification. Examples of
-transparent image formats include PNG, XCF and JPG. Opaque formats
-include proprietary formats that can be read and edited only by
-proprietary word processors, SGML or XML for which the DTD and/or
-processing tools are not generally available, and the
-machine-generated HTML, PostScript or PDF produced by some word
-processors for output purposes only.
-
-The "Title Page" means, for a printed book, the title page itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, "Title Page" means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
-The "publisher" means any person or entity that distributes copies of
-the Document to the public.
-
-A section "Entitled XYZ" means a named subunit of the Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as "Acknowledgements",
-"Dedications", "Endorsements", or "History".) To "Preserve the Title"
-of such a section when you modify the Document means that it remains a
-section "Entitled XYZ" according to this definition.
-
-The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
-2. VERBATIM COPYING
-
-You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no
-other conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
-You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
-
-3. COPYING IN QUANTITY
-
-If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
-If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
-If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
-It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to
-give them a chance to provide you with an updated version of the
-Document.
-
-
-4. MODIFICATIONS
-
-You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
-A. Use in the Title Page (and on the covers, if any) a title distinct
- from that of the Document, and from those of previous versions
- (which should, if there were any, be listed in the History section
- of the Document). You may use the same title as a previous version
- if the original publisher of that version gives permission.
-B. List on the Title Page, as authors, one or more persons or entities
- responsible for authorship of the modifications in the Modified
- Version, together with at least five of the principal authors of the
- Document (all of its principal authors, if it has fewer than five),
- unless they release you from this requirement.
-C. State on the Title page the name of the publisher of the
- Modified Version, as the publisher.
-D. Preserve all the copyright notices of the Document.
-E. Add an appropriate copyright notice for your modifications
- adjacent to the other copyright notices.
-F. Include, immediately after the copyright notices, a license notice
- giving the public permission to use the Modified Version under the
- terms of this License, in the form shown in the Addendum below.
-G. Preserve in that license notice the full lists of Invariant Sections
- and required Cover Texts given in the Document's license notice.
-H. Include an unaltered copy of this License.
-I. Preserve the section Entitled "History", Preserve its Title, and add
- to it an item stating at least the title, year, new authors, and
- publisher of the Modified Version as given on the Title Page. If
- there is no section Entitled "History" in the Document, create one
- stating the title, year, authors, and publisher of the Document as
- given on its Title Page, then add an item describing the Modified
- Version as stated in the previous sentence.
-J. Preserve the network location, if any, given in the Document for
- public access to a Transparent copy of the Document, and likewise
- the network locations given in the Document for previous versions
- it was based on. These may be placed in the "History" section.
- You may omit a network location for a work that was published at
- least four years before the Document itself, or if the original
- publisher of the version it refers to gives permission.
-K. For any section Entitled "Acknowledgements" or "Dedications",
- Preserve the Title of the section, and preserve in the section all
- the substance and tone of each of the contributor acknowledgements
- and/or dedications given therein.
-L. Preserve all the Invariant Sections of the Document,
- unaltered in their text and in their titles. Section numbers
- or the equivalent are not considered part of the section titles.
-M. Delete any section Entitled "Endorsements". Such a section
- may not be included in the Modified Version.
-N. Do not retitle any existing section to be Entitled "Endorsements"
- or to conflict in title with any Invariant Section.
-O. Preserve any Warranty Disclaimers.
-
-If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
-You may add a section Entitled "Endorsements", provided it contains
-nothing but endorsements of your Modified Version by various
-parties--for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
-You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
-The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
-
-5. COMBINING DOCUMENTS
-
-You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
-The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
-In the combination, you must combine any sections Entitled "History"
-in the various original documents, forming one section Entitled
-"History"; likewise combine any sections Entitled "Acknowledgements",
-and any sections Entitled "Dedications". You must delete all sections
-Entitled "Endorsements".
-
-
-6. COLLECTIONS OF DOCUMENTS
-
-You may make a collection consisting of the Document and other
-documents released under this License, and replace the individual
-copies of this License in the various documents with a single copy
-that is included in the collection, provided that you follow the rules
-of this License for verbatim copying of each of the documents in all
-other respects.
-
-You may extract a single document from such a collection, and
-distribute it individually under this License, provided you insert a
-copy of this License into the extracted document, and follow this
-License in all other respects regarding verbatim copying of that
-document.
-
-
-7. AGGREGATION WITH INDEPENDENT WORKS
-
-A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an "aggregate" if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included in an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
-If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
-
-8. TRANSLATION
-
-Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warranty Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
-If a section in the Document is Entitled "Acknowledgements",
-"Dedications", or "History", the requirement (section 4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
-
-9. TERMINATION
-
-You may not copy, modify, sublicense, or distribute the Document
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense, or distribute it is void, and
-will automatically terminate your rights under this License.
-
-However, if you cease all violation of this License, then your license
-from a particular copyright holder is reinstated (a) provisionally,
-unless and until the copyright holder explicitly and finally
-terminates your license, and (b) permanently, if the copyright holder
-fails to notify you of the violation by some reasonable means prior to
-60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, receipt of a copy of some or all of the same material does
-not give you any rights to use it.
-
-
-10. FUTURE REVISIONS OF THIS LICENSE
-
-The Free Software Foundation may publish new, revised versions of the
-GNU Free Documentation License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in
-detail to address new problems or concerns. See
-http://www.gnu.org/copyleft/.
-
-Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License "or any later version" applies to it, you have the option of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation. If the Document
-specifies that a proxy can decide which future versions of this
-License can be used, that proxy's public statement of acceptance of a
-version permanently authorizes you to choose that version for the
-Document.
-
-11. RELICENSING
-
-"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
-World Wide Web server that publishes copyrightable works and also
-provides prominent facilities for anybody to edit those works. A
-public wiki that anybody can edit is an example of such a server. A
-"Massive Multiauthor Collaboration" (or "MMC") contained in the site
-means any set of copyrightable works thus published on the MMC site.
-
-"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
-license published by Creative Commons Corporation, a not-for-profit
-corporation with a principal place of business in San Francisco,
-California, as well as future copyleft versions of that license
-published by that same organization.
-
-"Incorporate" means to publish or republish a Document, in whole or in
-part, as part of another Document.
-
-An MMC is "eligible for relicensing" if it is licensed under this
-License, and if all works that were first published under this License
-somewhere other than this MMC, and subsequently incorporated in whole or
-in part into the MMC, (1) had no cover texts or invariant sections, and
-(2) were thus incorporated prior to November 1, 2008.
-
-The operator of an MMC Site may republish an MMC contained in the site
-under CC-BY-SA on the same site at any time before August 1, 2009,
-provided the MMC is eligible for relicensing.
-
-
-ADDENDUM: How to use this License for your documents
-
-To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
- Copyright (c) YEAR YOUR NAME.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
- A copy of the license is included in the section entitled "GNU
- Free Documentation License".
-
-If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the "with...Texts." line with this:
-
- with the Invariant Sections being LIST THEIR TITLES, with the
- Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
-
-If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
-If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
Added: doc/info.txt
===================================================================
--- doc/info.txt (rev 0)
+++ doc/info.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -0,0 +1,19 @@
+Gbacker is a program to backup and restore files using a Gmail mail account.
+It uses the Gmail account as a remote file server.
+In contrast to other similar solutions like gdrive, gmailsync etc
+gbacker is fully compliant with the Gmail 'terms of use' and your not limited
+to a maximum of 500 uploads per 24 hours.
+With gbacker you can fully use the online storage space offered by Gmail.
+
+Gbacker is written in Python and uses sqlite3 for the database and GTK
+for the GUI.
+It uses the imap mail protocol and a sqlite database to mimic a remote directorytree.
+Gbacker can be used as a commandline application to backup and restore
+directories. It can also be used as a cron job to sync the backup.
+
+In addition to the commandline program there's also a GUI provided which
+acts as a two windowed file browser.
+
+Gbacker is designed to be as robust as possible even when the network connection
+is unstable. Great care is taken to ensure correct backups.
+
Modified: sf.txt
===================================================================
--- sf.txt 2009-12-03 13:14:23 UTC (rev 5)
+++ sf.txt 2009-12-03 14:17:59 UTC (rev 6)
@@ -1,7 +1,7 @@
Gbacker is a program to backup and restore files using a Gmail mail account.
It uses the Gmail account as a remote file server.
In contrast to other similar solutions like gdrive, gmailsync etc
-gbacker is fully compliant with the Gmail terms of use and your not limited
+gbacker is fully compliant with the Gmail 'terms of use' and your not limited
to a maximum of 500 uploads per 24 hours.
With gbacker you can fully use the online storage space offered by Gmail.
@@ -14,6 +14,6 @@
In addition to the commandline program there's also a GUI provided which
acts as a two windowed file browser.
-Gbacker is designed to be robust as possible even when the network connection
+Gbacker is designed to be as robust as possible even when the network connection
is unstable. Great care is taken to ensure correct backups.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 13:14:36
|
Revision: 5
http://gbacker.svn.sourceforge.net/gbacker/?rev=5&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 13:14:23 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
More work on GUI logic and fixing some bugs in Worker.
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Optparser.py
Worker.py
gbacker.py
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-02 14:14:04 UTC (rev 4)
+++ FileBrowserWidget.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -131,8 +131,10 @@
def get_show_only_dirs(self):
return self.show_only_dirs
- def get_selected(self):
- """ Returns selected item(s) in browser """
+ def get_selected(self, strip=False):
+ """ Returns selected item(s) in browser .
+ When @strip is True the part of the path that's added by the emptytree
+ is strip from the returnt paths."""
if not self.multiple_selection:
model, iter = self.view.get_selection().get_selected()
if iter != None:
@@ -232,7 +234,6 @@
return True
return True
-
def set_active_dir(self, directory):
# print "set_active_dir called with %s" % directory
if not directory:
@@ -332,10 +333,8 @@
newiter = model.iter_children(iter)
model.remove(newiter)
-
def get_file_list(self, model, iter, dir):
""" Get the file list from a given directory and put it in the treeview"""
-
ls = os.listdir(dir)
ls.sort(key=str.lower)
if self.sort_dir_files:
@@ -363,14 +362,18 @@
break
def create_root(self):
-
+ """sets the root for the tree widget.
+ It will strip parts of the root to prevent large trees of single dirs.
+ """
model = self.view.get_model()
if self.root != '/':
- if self.root[-1] == '/': self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ if self.root[-1] == '/':
+ self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ # Here we split the path and only keep the last directory
directory = self.root.split('/')[-1]
- else: directory = self.root
-
+ else:
+ directory = self.root
iter = model.insert_before(None, None)
model.set_value(iter, 0, self.get_folder_opened_icon())
model.set_value(iter, 1, directory)
@@ -396,12 +399,11 @@
self.popup.add(self.hidden_check_menu)
self.delete_menu = gtk.MenuItem(_("Delete file"))
- self.delete_menu.connect('activate', self.parent.delete_file, self)
+ self.delete_menu.connect('activate', self.parent.delete_local_file, self)
self.popup.add(self.delete_menu)
self.popup.show_all()
-
def get_folder_closed_icon(self):
""" Returns a pixbuf with the current theme closed folder icon """
@@ -418,7 +420,6 @@
#print "Can't load default icon"
return None
-
def get_folder_opened_icon(self):
""" Returns a pixbuf with the current theme opened folder icon """
@@ -435,7 +436,6 @@
#print "Can't load default icon"
return None
-
def get_file_icon(self):
""" Returns a pixbuf with the current theme file icon """
@@ -447,7 +447,6 @@
#print "Can't load icon", exc
return None
-
def sort_pathlist(self, ls, dir):
""" Sorts the list: dirs first, files last.
Returns a new list."""
@@ -467,7 +466,7 @@
def make_view(self):
""" Create the view itself.
- (Icon, dir name, path) """
+ (Icon, dir name, full path) """
self.model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
view = gtk.TreeView(self.model)
@@ -516,15 +515,26 @@
provided by gimap.
"""
def __init__(self,parent, root=None):
- """@account must be a gimap.ImapAccount instance on which the login method
- is called.
- As a reminder we override the standard Python modules os and os.path.
- Only the following os and os.path methods are provided:
- os.listdir, os.path.join and os.path.isdir.
- """
TreeFileBrowser.__init__(self, parent, root)
+
+
+ def create_popup(self):
+ """ Create popup menu for right click """
+ self.popup = gtk.Menu()
+
+ self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files"))
+ self.hidden_check_menu.connect('toggled', self.show_hidden_toggled)
+ self.popup.add(self.hidden_check_menu)
+ self.delete_menu = gtk.MenuItem(_("Delete file"))
+ self.delete_menu.connect('activate', self.parent.delete_remote_file, self)
+ self.popup.add(self.delete_menu)
+
+ self.popup.show_all()
+
+
+
if __name__ == "__main__":
from gettext import gettext as _
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-02 14:14:04 UTC (rev 4)
+++ GuiGtk.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -94,7 +94,7 @@
# We use this as a gui logger.
# Use it like this: self.gui.logger.write('hello world')
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
- self.guilogger.write("Start logger")
+ self.guilogger.write(_("Start logger"))
# add the treebrowser widget
self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
self.alignment_local.add(self.local_tree_widget.scrolled)
@@ -171,7 +171,7 @@
def on_button_connect_clicked(self, widget, *args):
# TODO: only one account from gbacker.rc supported
self.logger.debug('on_button_connect_clicked called with self.%s' % widget.get_name())
- self.guilogger.write("Connecting to Gmail account")
+ self.guilogger.write(_("Connecting to Gmail account"))
# get our account from the entrybox otherwise we use the default from
# the .gbacker/gbacker.rc file.
@@ -186,25 +186,26 @@
try:
self.ac.login_ssl(imap_user=account, imap_pass=pwrd)
except NoLoginError, e:
- self.guilogger.write("Failed to connect")
+ self.guilogger.write(_("Failed to connect"))
ErrorDialog(e)
else:
self.button_connect.set_sensitive(False)
self.button_disconnect.set_sensitive(True)
- self.guilogger.write("Connected to Gmail account %s" % account)
- self.guilogger.write("Building remote directory tree, please wait...")
- self.guilogger.write("done")
+ self.guilogger.write(_("Connected to Gmail account %s" % account))
+ self.guilogger.write(_("Building remote directory tree, please wait..."))
+ self.guilogger.write(_("done"))
self.connected = True
# add the remote treebrowser widget
- # The first part of the emptytree is stripped from the view
- self.remote_tree_widget = RemoteTreeFileBrowser(self, os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
+ # The first part of the emptytree is stripped from the view in create_root
+ root = os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:])
+ self.remote_tree_widget = RemoteTreeFileBrowser(self, root)
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
return True
def on_button_disconnect_clicked(self, widget, *args):
self.logger.debug('on_button_disconnect_clicked called with %s' % widget)
- self.guilogger.write("Disconnecting from Gmail account")
+ self.guilogger.write(_("Disconnecting from Gmail account"))
try:
self.ac.logout()
except AttributeError:
@@ -220,16 +221,16 @@
# upload selection
self.logger.debug('on_button_arrow_right_clicked called with self.%s' % widget.get_name())
if not self.connected:
- self.guilogger.write("Not connected")
- self.guilogger.write("Please connect to a Gmail account first.")
+ self.guilogger.write(_("Not connected"))
+ self.guilogger.write(_("Please connect to a Gmail account first."))
return
selectedfiles = self.local_tree_widget.get_selected()
self.logger.debug("selected files: %s" % selectedfiles)
if not selectedfiles:
- self.guilogger.write("No files selected, nothing to upload")
+ self.guilogger.write(_("No files selected, nothing to upload"))
return True
else:
- self.guilogger.write("%s files selected, starting to upload" % len(selectedfiles))
+ self.guilogger.write(_("%s files selected, starting to upload" % len(selectedfiles)))
self.frame_pbar.show_all()
for item in selectedfiles:
@@ -245,8 +246,8 @@
#download selection
self.logger.debug('on_button_arrow_left_clicked called with self.%s' % widget.get_name())
if not self.connected:
- self.guilogger.write("Not connected")
- self.guilogger.write("Please connect to a Gmail account first.")
+ self.guilogger.write(_("Not connected"))
+ self.guilogger.write(_("Please connect to a Gmail account first."))
return
targetdirectory = self.local_tree_widget.get_selected()
if not targetdirectory:
@@ -256,14 +257,15 @@
if os.path.isdir(path):
target = path
break
- self.logger.debug("download target directory: %s" % target)
- selectedfiles = self.remote_tree_widget.get_selected()
+ self.logger.debug("download target directory: %s" % target)
+
+ selectedfiles = self.remote_tree_widget.get_selected()
self.logger.debug("selected files: %s" % selectedfiles)
if not selectedfiles:
- self.guilogger.write("No files selected, nothing to download")
+ self.guilogger.write(_("No files selected, nothing to download"))
return True
else:
- self.guilogger.write("%s files selected, starting to download" % len(selectedfiles))
+ self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
@@ -286,44 +288,75 @@
model.insert(0, [self.accountname])
self.comboboxentry_account.set_active(0)
- def delete_file(self, widget, tree):
- """Callback for the popup menu item 'delete file' in the TreeFileBrowser"""
- print "delete_file", tree.get_selected()
+ def delete_local_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the local TreeFileBrowser"""
+ paths = tree.get_selected()
+ if not paths:
+ InfoDialog(_("No files selected to delete."))
+ return
+ self.logger.debug("delete_local_file called with: %s" % paths)
+ dlg = YesNoDialog(txt='Do you want to delete:\n %s \nand all the files it contains ?' % '\n'.join(paths))
+ response = dlg.run()
+ dlg.destroy()
+ if response == gtk.RESPONSE_NO:
+ self.logger.debug("dialog response is no, not deleting selection")
+ return
+ def delete_remote_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the remote TreeFileBrowser"""
+ paths = tree.get_selected()
+ if not paths:
+ InfoDialog(_("No files selected to delete."))
+ return
+ self.logger.debug("delete_remote_file called with: %s" % paths)
+ dlg = YesNoDialog(txt='Do you want to delete:\n %s \nand all the files it contains ?' % '\n'.join(paths))
+ response = dlg.run()
+ dlg.destroy()
+ if response == gtk.RESPONSE_NO:
+ self.logger.debug("dialog response is no, not deleting selection")
+ return
+ for path in paths:
+ self.guilogger.write(_("Deleting %s" % path))
+ if os.path.isdir(path):
+ self.worker.delete_remote_dir(path)
+ else:
+ self.worker.delete_remote_file(path)
+ self.guilogger.write(_("done"))
+
######## Various internally used methods ############
def _upload_file(self, file):
- self.guilogger.write("Uploading %s" % file)
+ self.guilogger.write(_("Uploading %s" % file))
pp = PbarPulser(self.pbar)
pp.start()
result = self.worker.upload_file(file)
pp.stop()
if result:
- self.guilogger.write("done.")
+ self.guilogger.write(_("done."))
else:
- self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ self.guilogger.write(_("failed, check the logs in %s." % LOGPATH))
def _download_file(self, file, target=None):
- self.guilogger.write("Downloading %s to %s" % (file, target))
+ self.guilogger.write(_("Downloading %s to %s" % (file, target)))
pp = PbarPulser(self.pbar)
pp.start()
result = self.worker.download_file(file, dest=target)
pp.stop()
if result:
- self.guilogger.write("done.")
+ self.guilogger.write(_("done."))
else:
- self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ self.guilogger.write(_("failed, check the logs in %s." % LOGPATH))
return result
def end_this_show(self):
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
- self.guilogger.write("Stopping all processes")
+ self.guilogger.write(_("Stopping all processes"))
try:
self.worker.stop()
except:
pass
- self.guilogger.write("Stop logger")
+ self.guilogger.write(_("Stop logger"))
try:
f = open(IBSIGGUILOGPATH, 'w')
f.writelines(self.guilogger.get_logreport())
@@ -429,6 +462,11 @@
txt=txt)
class YesNoDialog(gtk.MessageDialog):
+ """YesNoDialog is different as we want a respons value
+ dlg = YesNoDialog(txt='YesNoDialog')
+ respons = dlg.run()
+ print 'respons from YesNoDialog',respons
+ """
def __init__(self,parent=None,flags=gtk.DIALOG_MODAL,type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_YES_NO,message_format='',txt=''):
gtk.MessageDialog.__init__(self,parent=parent,
@@ -436,6 +474,5 @@
type=type,
buttons=buttons,
message_format=message_format)
- #self.connect("response", self.response)
self.set_markup('%s%s%s' % ('<b>',txt,'</b>'))
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-02 14:14:04 UTC (rev 4)
+++ Optparser.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -28,8 +28,9 @@
usage = "usage: %prog [options]"
OptionParser.__init__(self,usage=usage,version=version)
# set some reasonable defaults
- self.set_defaults(loglevel="debug"
- )
+ self.set_defaults(loglevel="debug",\
+ imap_port="993",\
+ imap_server="imap.gmail.com")
# add possible options to the parser
self.add_option("-l", "--loglevel",
help="Set logging level. Possible values are: debug,info,warning,error,critical",
@@ -55,6 +56,10 @@
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
dest="destination")
+ self.add_option("-a", "--rebuilddb",
+ help="Rebuilds the database ",
+ dest="destination")
+
(self.options, self.args) = self.parse_args()
def exit(self,*args):
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-02 14:14:04 UTC (rev 4)
+++ Worker.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -305,8 +305,13 @@
for filename in files:
filelist.append(os.path.join(root,filename))
return filelist
+
+ def get_original_paths(self, pathlist):
+ """strips the emptytree root from the paths.
+ This is usefull as the GUI returns full paths from the emptytree
+ which starts with the temp root."""
+ return [p.replace(self.root, '', 1) for p in pathlist]
-
class DB:
"""Handles all the sqlite3 stuff.
For more info about the sqlite3 table(s) used, see the file README.sqlite."""
@@ -505,7 +510,14 @@
for path in filelist:
self.ce(''' DELETE FROM messages WHERE path=? ''', (path,))
self.conn.commit()
-
+
+ def remove_file(self, file):
+ """Called by worker when it deletes a remote file.
+ @filelist is a file path."""
+ self.logger.debug("remove_file called with %s" % file)
+ self.ce(''' DELETE FROM messages WHERE path=? ''', (file,))
+ self.conn.commit()
+
def new_message_send(self, result):
"""Called when uploader send the message.
@result will be True if message was send successfully, False when it failed.
@@ -653,6 +665,16 @@
self.sendreport = {}
self.build_remote_tree()
atexit.register(self.stop)
+
+ ####### some shortcut methods for the GUI
+ def strip_paths(self, pathlist):
+ """Fullpaths from the GUI contain the root path from the empty tree.
+ The GUI calls this method to get rid of the emptytree part.
+ As the emtytree is the only one who knows about it's root pathwe pass
+ this call to the treebuilder object."""
+ return self.treebuilder.get_original_paths(pathlist)
+
+ #####################################
def stop(self):
"""Do some cleanup and make sure we shutdown the dbase properly."""
@@ -713,6 +735,8 @@
Use this with care. This will also update the dbase and the empty tree.
Returns True on success or raises a ServerError when it fails.
"""
+ # strip the emptytree part form the path
+ directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("delete_remote_dir called with: %s" % directory)
# XXX This doesn't work properly. It doesn't move the last message to the
# trash. It says it does but it doesn't.
@@ -735,12 +759,14 @@
self.treebuilder.remove_directory(directory)
return True
- def delete_file(self, path):
+ def delete_remote_file(self, path):
"""Delete the remote file (message).
Warning, deleted messages and their contents can NOT be restored.
Use this with care. This will also update the dbase and the empty tree.
Returns True on success or raises a ServerError when it fails.
"""
+ # strip the emptytree part form the path
+ path = path.replace(self.treeroot[0], '', 1)
self.logger.debug("delete_remote_file called with: %s" % path)
mesg_id = self.ac.get_id('[Gmail]/Drafts','(SUBJECT ##%s##)' % path)
if not mesg_id:
@@ -751,8 +777,8 @@
# TODO: How can we keep the dbase in sync with gmail account?
else:
# update dbase which will update the empty tree
- self.db.remove_directory(path)
- self.treebuilder.remove_directory(path)
+ self.db.remove_file(path)
+ self.treebuilder.remove_file(path)
return True
def upload_file(self, filename):
@@ -835,7 +861,7 @@
It will use @dest as the root directory. When @dest is None the original
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails."""
- print "treeroot", self.treeroot
+ # strip the emptytree part form the path
path = path.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for ##%s##" % path)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT ##%s##)' % path)
@@ -850,6 +876,8 @@
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails.
"""
+ # strip the emptytree part form the path
+ directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for %s##" % directory)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT %s##)' % directory)
self.logger.debug("download_directory found megs_ids: %s" % mesg_ids)
Modified: gbacker.py
===================================================================
--- gbacker.py 2009-12-02 14:14:04 UTC (rev 4)
+++ gbacker.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -61,6 +61,15 @@
w.upload_directory(CMD_Options.backup)
elif CMD_Options.restore:
w.download_directory(CMD_Options.restore, CMD_Options.destination)
+
+elif CMD_Options.rebuilddb:
+ from gimap import ImapAccount
+ from Worker import Worker
+ ac = ImapAccount()
+ server = ac.login_ssl()
+ w = Worker(ac)
+ w.rebuild_dbase()
+
else:
from GuiGtk import MainWindow
win = MainWindow(options=vars(CMD_Options))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-03 13:14:36
|
Revision: 5
http://gbacker.svn.sourceforge.net/gbacker/?rev=5&view=rev
Author: stas_zytkiewicz
Date: 2009-12-03 13:14:23 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
More work on GUI logic and fixing some bugs in Worker.
Modified Paths:
--------------
FileBrowserWidget.py
GuiGtk.py
Optparser.py
Worker.py
gbacker.py
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-12-02 14:14:04 UTC (rev 4)
+++ FileBrowserWidget.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -131,8 +131,10 @@
def get_show_only_dirs(self):
return self.show_only_dirs
- def get_selected(self):
- """ Returns selected item(s) in browser """
+ def get_selected(self, strip=False):
+ """ Returns selected item(s) in browser .
+ When @strip is True the part of the path that's added by the emptytree
+ is strip from the returnt paths."""
if not self.multiple_selection:
model, iter = self.view.get_selection().get_selected()
if iter != None:
@@ -232,7 +234,6 @@
return True
return True
-
def set_active_dir(self, directory):
# print "set_active_dir called with %s" % directory
if not directory:
@@ -332,10 +333,8 @@
newiter = model.iter_children(iter)
model.remove(newiter)
-
def get_file_list(self, model, iter, dir):
""" Get the file list from a given directory and put it in the treeview"""
-
ls = os.listdir(dir)
ls.sort(key=str.lower)
if self.sort_dir_files:
@@ -363,14 +362,18 @@
break
def create_root(self):
-
+ """sets the root for the tree widget.
+ It will strip parts of the root to prevent large trees of single dirs.
+ """
model = self.view.get_model()
if self.root != '/':
- if self.root[-1] == '/': self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ if self.root[-1] == '/':
+ self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary
+ # Here we split the path and only keep the last directory
directory = self.root.split('/')[-1]
- else: directory = self.root
-
+ else:
+ directory = self.root
iter = model.insert_before(None, None)
model.set_value(iter, 0, self.get_folder_opened_icon())
model.set_value(iter, 1, directory)
@@ -396,12 +399,11 @@
self.popup.add(self.hidden_check_menu)
self.delete_menu = gtk.MenuItem(_("Delete file"))
- self.delete_menu.connect('activate', self.parent.delete_file, self)
+ self.delete_menu.connect('activate', self.parent.delete_local_file, self)
self.popup.add(self.delete_menu)
self.popup.show_all()
-
def get_folder_closed_icon(self):
""" Returns a pixbuf with the current theme closed folder icon """
@@ -418,7 +420,6 @@
#print "Can't load default icon"
return None
-
def get_folder_opened_icon(self):
""" Returns a pixbuf with the current theme opened folder icon """
@@ -435,7 +436,6 @@
#print "Can't load default icon"
return None
-
def get_file_icon(self):
""" Returns a pixbuf with the current theme file icon """
@@ -447,7 +447,6 @@
#print "Can't load icon", exc
return None
-
def sort_pathlist(self, ls, dir):
""" Sorts the list: dirs first, files last.
Returns a new list."""
@@ -467,7 +466,7 @@
def make_view(self):
""" Create the view itself.
- (Icon, dir name, path) """
+ (Icon, dir name, full path) """
self.model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
view = gtk.TreeView(self.model)
@@ -516,15 +515,26 @@
provided by gimap.
"""
def __init__(self,parent, root=None):
- """@account must be a gimap.ImapAccount instance on which the login method
- is called.
- As a reminder we override the standard Python modules os and os.path.
- Only the following os and os.path methods are provided:
- os.listdir, os.path.join and os.path.isdir.
- """
TreeFileBrowser.__init__(self, parent, root)
+
+
+ def create_popup(self):
+ """ Create popup menu for right click """
+ self.popup = gtk.Menu()
+
+ self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files"))
+ self.hidden_check_menu.connect('toggled', self.show_hidden_toggled)
+ self.popup.add(self.hidden_check_menu)
+ self.delete_menu = gtk.MenuItem(_("Delete file"))
+ self.delete_menu.connect('activate', self.parent.delete_remote_file, self)
+ self.popup.add(self.delete_menu)
+
+ self.popup.show_all()
+
+
+
if __name__ == "__main__":
from gettext import gettext as _
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-12-02 14:14:04 UTC (rev 4)
+++ GuiGtk.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -94,7 +94,7 @@
# We use this as a gui logger.
# Use it like this: self.gui.logger.write('hello world')
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
- self.guilogger.write("Start logger")
+ self.guilogger.write(_("Start logger"))
# add the treebrowser widget
self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
self.alignment_local.add(self.local_tree_widget.scrolled)
@@ -171,7 +171,7 @@
def on_button_connect_clicked(self, widget, *args):
# TODO: only one account from gbacker.rc supported
self.logger.debug('on_button_connect_clicked called with self.%s' % widget.get_name())
- self.guilogger.write("Connecting to Gmail account")
+ self.guilogger.write(_("Connecting to Gmail account"))
# get our account from the entrybox otherwise we use the default from
# the .gbacker/gbacker.rc file.
@@ -186,25 +186,26 @@
try:
self.ac.login_ssl(imap_user=account, imap_pass=pwrd)
except NoLoginError, e:
- self.guilogger.write("Failed to connect")
+ self.guilogger.write(_("Failed to connect"))
ErrorDialog(e)
else:
self.button_connect.set_sensitive(False)
self.button_disconnect.set_sensitive(True)
- self.guilogger.write("Connected to Gmail account %s" % account)
- self.guilogger.write("Building remote directory tree, please wait...")
- self.guilogger.write("done")
+ self.guilogger.write(_("Connected to Gmail account %s" % account))
+ self.guilogger.write(_("Building remote directory tree, please wait..."))
+ self.guilogger.write(_("done"))
self.connected = True
# add the remote treebrowser widget
- # The first part of the emptytree is stripped from the view
- self.remote_tree_widget = RemoteTreeFileBrowser(self, os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
+ # The first part of the emptytree is stripped from the view in create_root
+ root = os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:])
+ self.remote_tree_widget = RemoteTreeFileBrowser(self, root)
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
return True
def on_button_disconnect_clicked(self, widget, *args):
self.logger.debug('on_button_disconnect_clicked called with %s' % widget)
- self.guilogger.write("Disconnecting from Gmail account")
+ self.guilogger.write(_("Disconnecting from Gmail account"))
try:
self.ac.logout()
except AttributeError:
@@ -220,16 +221,16 @@
# upload selection
self.logger.debug('on_button_arrow_right_clicked called with self.%s' % widget.get_name())
if not self.connected:
- self.guilogger.write("Not connected")
- self.guilogger.write("Please connect to a Gmail account first.")
+ self.guilogger.write(_("Not connected"))
+ self.guilogger.write(_("Please connect to a Gmail account first."))
return
selectedfiles = self.local_tree_widget.get_selected()
self.logger.debug("selected files: %s" % selectedfiles)
if not selectedfiles:
- self.guilogger.write("No files selected, nothing to upload")
+ self.guilogger.write(_("No files selected, nothing to upload"))
return True
else:
- self.guilogger.write("%s files selected, starting to upload" % len(selectedfiles))
+ self.guilogger.write(_("%s files selected, starting to upload" % len(selectedfiles)))
self.frame_pbar.show_all()
for item in selectedfiles:
@@ -245,8 +246,8 @@
#download selection
self.logger.debug('on_button_arrow_left_clicked called with self.%s' % widget.get_name())
if not self.connected:
- self.guilogger.write("Not connected")
- self.guilogger.write("Please connect to a Gmail account first.")
+ self.guilogger.write(_("Not connected"))
+ self.guilogger.write(_("Please connect to a Gmail account first."))
return
targetdirectory = self.local_tree_widget.get_selected()
if not targetdirectory:
@@ -256,14 +257,15 @@
if os.path.isdir(path):
target = path
break
- self.logger.debug("download target directory: %s" % target)
- selectedfiles = self.remote_tree_widget.get_selected()
+ self.logger.debug("download target directory: %s" % target)
+
+ selectedfiles = self.remote_tree_widget.get_selected()
self.logger.debug("selected files: %s" % selectedfiles)
if not selectedfiles:
- self.guilogger.write("No files selected, nothing to download")
+ self.guilogger.write(_("No files selected, nothing to download"))
return True
else:
- self.guilogger.write("%s files selected, starting to download" % len(selectedfiles))
+ self.guilogger.write(_("%s files selected, starting to download" % len(selectedfiles)))
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
@@ -286,44 +288,75 @@
model.insert(0, [self.accountname])
self.comboboxentry_account.set_active(0)
- def delete_file(self, widget, tree):
- """Callback for the popup menu item 'delete file' in the TreeFileBrowser"""
- print "delete_file", tree.get_selected()
+ def delete_local_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the local TreeFileBrowser"""
+ paths = tree.get_selected()
+ if not paths:
+ InfoDialog(_("No files selected to delete."))
+ return
+ self.logger.debug("delete_local_file called with: %s" % paths)
+ dlg = YesNoDialog(txt='Do you want to delete:\n %s \nand all the files it contains ?' % '\n'.join(paths))
+ response = dlg.run()
+ dlg.destroy()
+ if response == gtk.RESPONSE_NO:
+ self.logger.debug("dialog response is no, not deleting selection")
+ return
+ def delete_remote_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the remote TreeFileBrowser"""
+ paths = tree.get_selected()
+ if not paths:
+ InfoDialog(_("No files selected to delete."))
+ return
+ self.logger.debug("delete_remote_file called with: %s" % paths)
+ dlg = YesNoDialog(txt='Do you want to delete:\n %s \nand all the files it contains ?' % '\n'.join(paths))
+ response = dlg.run()
+ dlg.destroy()
+ if response == gtk.RESPONSE_NO:
+ self.logger.debug("dialog response is no, not deleting selection")
+ return
+ for path in paths:
+ self.guilogger.write(_("Deleting %s" % path))
+ if os.path.isdir(path):
+ self.worker.delete_remote_dir(path)
+ else:
+ self.worker.delete_remote_file(path)
+ self.guilogger.write(_("done"))
+
######## Various internally used methods ############
def _upload_file(self, file):
- self.guilogger.write("Uploading %s" % file)
+ self.guilogger.write(_("Uploading %s" % file))
pp = PbarPulser(self.pbar)
pp.start()
result = self.worker.upload_file(file)
pp.stop()
if result:
- self.guilogger.write("done.")
+ self.guilogger.write(_("done."))
else:
- self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ self.guilogger.write(_("failed, check the logs in %s." % LOGPATH))
def _download_file(self, file, target=None):
- self.guilogger.write("Downloading %s to %s" % (file, target))
+ self.guilogger.write(_("Downloading %s to %s" % (file, target)))
pp = PbarPulser(self.pbar)
pp.start()
result = self.worker.download_file(file, dest=target)
pp.stop()
if result:
- self.guilogger.write("done.")
+ self.guilogger.write(_("done."))
else:
- self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ self.guilogger.write(_("failed, check the logs in %s." % LOGPATH))
return result
def end_this_show(self):
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
- self.guilogger.write("Stopping all processes")
+ self.guilogger.write(_("Stopping all processes"))
try:
self.worker.stop()
except:
pass
- self.guilogger.write("Stop logger")
+ self.guilogger.write(_("Stop logger"))
try:
f = open(IBSIGGUILOGPATH, 'w')
f.writelines(self.guilogger.get_logreport())
@@ -429,6 +462,11 @@
txt=txt)
class YesNoDialog(gtk.MessageDialog):
+ """YesNoDialog is different as we want a respons value
+ dlg = YesNoDialog(txt='YesNoDialog')
+ respons = dlg.run()
+ print 'respons from YesNoDialog',respons
+ """
def __init__(self,parent=None,flags=gtk.DIALOG_MODAL,type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_YES_NO,message_format='',txt=''):
gtk.MessageDialog.__init__(self,parent=parent,
@@ -436,6 +474,5 @@
type=type,
buttons=buttons,
message_format=message_format)
- #self.connect("response", self.response)
self.set_markup('%s%s%s' % ('<b>',txt,'</b>'))
Modified: Optparser.py
===================================================================
--- Optparser.py 2009-12-02 14:14:04 UTC (rev 4)
+++ Optparser.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -28,8 +28,9 @@
usage = "usage: %prog [options]"
OptionParser.__init__(self,usage=usage,version=version)
# set some reasonable defaults
- self.set_defaults(loglevel="debug"
- )
+ self.set_defaults(loglevel="debug",\
+ imap_port="993",\
+ imap_server="imap.gmail.com")
# add possible options to the parser
self.add_option("-l", "--loglevel",
help="Set logging level. Possible values are: debug,info,warning,error,critical",
@@ -55,6 +56,10 @@
self.add_option("-d", "--destination",
help="Use this in combination with option -r to give a target destination for the download",
dest="destination")
+ self.add_option("-a", "--rebuilddb",
+ help="Rebuilds the database ",
+ dest="destination")
+
(self.options, self.args) = self.parse_args()
def exit(self,*args):
Modified: Worker.py
===================================================================
--- Worker.py 2009-12-02 14:14:04 UTC (rev 4)
+++ Worker.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -305,8 +305,13 @@
for filename in files:
filelist.append(os.path.join(root,filename))
return filelist
+
+ def get_original_paths(self, pathlist):
+ """strips the emptytree root from the paths.
+ This is usefull as the GUI returns full paths from the emptytree
+ which starts with the temp root."""
+ return [p.replace(self.root, '', 1) for p in pathlist]
-
class DB:
"""Handles all the sqlite3 stuff.
For more info about the sqlite3 table(s) used, see the file README.sqlite."""
@@ -505,7 +510,14 @@
for path in filelist:
self.ce(''' DELETE FROM messages WHERE path=? ''', (path,))
self.conn.commit()
-
+
+ def remove_file(self, file):
+ """Called by worker when it deletes a remote file.
+ @filelist is a file path."""
+ self.logger.debug("remove_file called with %s" % file)
+ self.ce(''' DELETE FROM messages WHERE path=? ''', (file,))
+ self.conn.commit()
+
def new_message_send(self, result):
"""Called when uploader send the message.
@result will be True if message was send successfully, False when it failed.
@@ -653,6 +665,16 @@
self.sendreport = {}
self.build_remote_tree()
atexit.register(self.stop)
+
+ ####### some shortcut methods for the GUI
+ def strip_paths(self, pathlist):
+ """Fullpaths from the GUI contain the root path from the empty tree.
+ The GUI calls this method to get rid of the emptytree part.
+ As the emtytree is the only one who knows about it's root pathwe pass
+ this call to the treebuilder object."""
+ return self.treebuilder.get_original_paths(pathlist)
+
+ #####################################
def stop(self):
"""Do some cleanup and make sure we shutdown the dbase properly."""
@@ -713,6 +735,8 @@
Use this with care. This will also update the dbase and the empty tree.
Returns True on success or raises a ServerError when it fails.
"""
+ # strip the emptytree part form the path
+ directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("delete_remote_dir called with: %s" % directory)
# XXX This doesn't work properly. It doesn't move the last message to the
# trash. It says it does but it doesn't.
@@ -735,12 +759,14 @@
self.treebuilder.remove_directory(directory)
return True
- def delete_file(self, path):
+ def delete_remote_file(self, path):
"""Delete the remote file (message).
Warning, deleted messages and their contents can NOT be restored.
Use this with care. This will also update the dbase and the empty tree.
Returns True on success or raises a ServerError when it fails.
"""
+ # strip the emptytree part form the path
+ path = path.replace(self.treeroot[0], '', 1)
self.logger.debug("delete_remote_file called with: %s" % path)
mesg_id = self.ac.get_id('[Gmail]/Drafts','(SUBJECT ##%s##)' % path)
if not mesg_id:
@@ -751,8 +777,8 @@
# TODO: How can we keep the dbase in sync with gmail account?
else:
# update dbase which will update the empty tree
- self.db.remove_directory(path)
- self.treebuilder.remove_directory(path)
+ self.db.remove_file(path)
+ self.treebuilder.remove_file(path)
return True
def upload_file(self, filename):
@@ -835,7 +861,7 @@
It will use @dest as the root directory. When @dest is None the original
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails."""
- print "treeroot", self.treeroot
+ # strip the emptytree part form the path
path = path.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for ##%s##" % path)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT ##%s##)' % path)
@@ -850,6 +876,8 @@
path from the filename is used as the destination path.
Returns True on success or raises a WriteError when it fails.
"""
+ # strip the emptytree part form the path
+ directory = directory.replace(self.treeroot[0], '', 1)
self.logger.debug("searching for %s##" % directory)
mesg_ids = self.ac.get_id('[Gmail]/Drafts','(SUBJECT %s##)' % directory)
self.logger.debug("download_directory found megs_ids: %s" % mesg_ids)
Modified: gbacker.py
===================================================================
--- gbacker.py 2009-12-02 14:14:04 UTC (rev 4)
+++ gbacker.py 2009-12-03 13:14:23 UTC (rev 5)
@@ -61,6 +61,15 @@
w.upload_directory(CMD_Options.backup)
elif CMD_Options.restore:
w.download_directory(CMD_Options.restore, CMD_Options.destination)
+
+elif CMD_Options.rebuilddb:
+ from gimap import ImapAccount
+ from Worker import Worker
+ ac = ImapAccount()
+ server = ac.login_ssl()
+ w = Worker(ac)
+ w.rebuild_dbase()
+
else:
from GuiGtk import MainWindow
win = MainWindow(options=vars(CMD_Options))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-02 14:14:16
|
Revision: 4
http://gbacker.svn.sourceforge.net/gbacker/?rev=4&view=rev
Author: stas_zytkiewicz
Date: 2009-12-02 14:14:04 +0000 (Wed, 02 Dec 2009)
Log Message:
-----------
More work on the gui part
Modified Paths:
--------------
Constants.py
FileBrowserWidget.py
GuiGtk.py
glade/gui.ui
Modified: Constants.py
===================================================================
--- Constants.py 2009-11-29 13:42:08 UTC (rev 3)
+++ Constants.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -1,12 +1,19 @@
# Constants used by gbacker
import os
-
+import sys
# Packagers, make sure to change the IBSIGRCPATH to the directory path
# where gbacker.rc is found.
# Further below we copy gbacker.rc into the users dir.
BASEIBSIGRCPATH = os.getcwd()
# Some constants
+if sys.platform == 'win32':
+ try:
+ ROOTPATH = os.environ['HOMEDRIVE']
+ except:
+ ROOTPATH = 'c:/'
+else:
+ ROOTPATH = '/'
HOMEDIR = os.path.expanduser('~')
APPNAME = 'gbacker'
LOGPATH = os.path.join(HOMEDIR,'.gbacker', APPNAME+".log")
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-11-29 13:42:08 UTC (rev 3)
+++ FileBrowserWidget.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -48,9 +48,9 @@
'cursor-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
}
- def __init__(self, root=None):
+ def __init__(self, parent, root=None):
""" root is where we want the tree initialized """
-
+ self.parent = parent
gobject.GObject.__init__(self)
self.show_hidden = False
@@ -212,7 +212,7 @@
state = widget.get_active()
self.set_show_hidden(state)
-
+
#####################################################
# Directories and files, nodes and icons
@@ -393,8 +393,12 @@
self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files"))
self.hidden_check_menu.connect('toggled', self.show_hidden_toggled)
-
self.popup.add(self.hidden_check_menu)
+
+ self.delete_menu = gtk.MenuItem(_("Delete file"))
+ self.delete_menu.connect('activate', self.parent.delete_file, self)
+ self.popup.add(self.delete_menu)
+
self.popup.show_all()
@@ -511,31 +515,15 @@
This way we can use the TreeFileBrowser for directory like structures as
provided by gimap.
"""
- def __init__(self, root=None):
+ def __init__(self,parent, root=None):
"""@account must be a gimap.ImapAccount instance on which the login method
is called.
As a reminder we override the standard Python modules os and os.path.
Only the following os and os.path methods are provided:
os.listdir, os.path.join and os.path.isdir.
"""
- TreeFileBrowser.__init__(self, root)
+ TreeFileBrowser.__init__(self, parent, root)
- def get_selected(self):
- """ Returns selected item(s) in browser """
- if not self.multiple_selection:
- model, iter = self.view.get_selection().get_selected()
- if iter != None:
- return model.get_value(iter, 2)
- else:
- return None
- else:
- model, selected = self.view.get_selection().get_selected_rows()
- if selected != None:
- ls = []
- iters = [model.get_iter(path) for path in selected]
- for iter in iters:
- ls.append(model.get_value(iter, 2))
- return ls
if __name__ == "__main__":
from gettext import gettext as _
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-11-29 13:42:08 UTC (rev 3)
+++ GuiGtk.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -23,6 +23,8 @@
import sys
import logging
import glob
+import time
+import threading
module_logger = logging.getLogger('gbacker.GuiGtk')
@@ -46,6 +48,9 @@
except ImportError:
module_logger.error("No pango package found, stopping.")
sys.exit(1)
+
+#Initializing the gtk's thread engine
+gtk.gdk.threads_init
import gobject
import time
@@ -91,11 +96,16 @@
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
self.guilogger.write("Start logger")
# add the treebrowser widget
- self.local_tree_widget = TreeFileBrowser(os.path.expanduser('~'))
+ self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
+ self.remote_tree_widget = None
self.window1.show_all()
-
+ # setup our threaded progressbar
+ self.pbar = gtk.ProgressBar()
+ self.pbar.set_pulse_step(0.1)
+ self.alignment_pbar.add(self.pbar)
+
def on_window1_delete_event(self, widget, *args):
self.logger.debug('on_window1_delete_event called with self.%s' % widget.get_name())
# placeholder: 'do you want to quit' dialog
@@ -112,12 +122,12 @@
self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
return True
- def on_local_rename_directory_activated(self, widget, *args):
- self.logger.debug('on_local_rename_directory_activated called with self.%s' % widget.get_name())
+ def on_local_rename_activated(self, widget, *args):
+ self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
return True
- def on_local_delete_directory_activated(self, widget, *args):
- self.logger.debug('on_local_delete_directory_activated called with self.%s' % widget.get_name())
+ def on_local_delete_activated(self, widget, *args):
+ self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
return True
def on_local_upload_directory_activated(self, widget, *args):
@@ -128,12 +138,12 @@
self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
return True
- def on_remote_rename_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_rename_directory_activated called with self.%s' % widget.get_name())
+ def on_remote_rename_activated(self, widget, *args):
+ self.logger.debug('on_remote_rename_activated called with self.%s' % widget.get_name())
return True
- def on_remote_delete_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_delete_directory_activated called with self.%s' % widget.get_name())
+ def on_remote_delete_activated(self, widget, *args):
+ self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
return True
def on_remote_download_directory_activated(self, widget, *args):
@@ -187,7 +197,7 @@
self.connected = True
# add the remote treebrowser widget
# The first part of the emptytree is stripped from the view
- self.remote_tree_widget = RemoteTreeFileBrowser(os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
+ self.remote_tree_widget = RemoteTreeFileBrowser(self, os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
return True
@@ -202,7 +212,8 @@
self.button_disconnect.set_sensitive(False)
self.button_connect.set_sensitive(True)
self.connected = False
- self.remote_tree_widget.view.hide()
+ if self.remote_tree_widget:
+ self.remote_tree_widget.view.hide()
return True
def on_button_arrow_right_clicked(self, widget, *args):
@@ -219,16 +230,15 @@
return True
else:
self.guilogger.write("%s files selected, starting to upload" % len(selectedfiles))
+
+ self.frame_pbar.show_all()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
- self.guilogger.write("Uploading %s" % file)
- self.worker.upload_file(file)
- self.guilogger.write("done.")
+ self._upload_file(file)
else:
- self.guilogger.write("Uploading %s" % item)
- self.worker.upload_file(item)
- self.guilogger.write("done.")
+ self._upload_file(item)
+ self.frame_pbar.hide()
return True
def on_button_arrow_left_clicked(self, widget, *args):
@@ -240,7 +250,7 @@
return
targetdirectory = self.local_tree_widget.get_selected()
if not targetdirectory:
- target = os.path.expanduser('~')
+ target = os.path.expanduser(ROOTPATH)
else:
for path in targetdirectory:
if os.path.isdir(path):
@@ -257,17 +267,9 @@
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
- self.guilogger.write("Downloading %s to %s" % (file, target))
- if self.worker.download_file(file, dest=target):
- self.guilogger.write("done.")
- else:
- self.guilogger.write("failed")
+ self._download_file(file, target)
else:
- self.guilogger.write("Downloading %s to %s" % (item, target))
- if self.worker.download_file(item, dest=target):
- self.guilogger.write("done.")
- else:
- self.guilogger.write("failed")
+ self._download_file(item, target)
return True
###### Non-glade callbacks ############
@@ -283,10 +285,36 @@
self.accountname = combobox.get_text()
model.insert(0, [self.accountname])
self.comboboxentry_account.set_active(0)
+
+ def delete_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the TreeFileBrowser"""
+ print "delete_file", tree.get_selected()
-
######## Various internally used methods ############
-
+
+ def _upload_file(self, file):
+ self.guilogger.write("Uploading %s" % file)
+ pp = PbarPulser(self.pbar)
+ pp.start()
+ result = self.worker.upload_file(file)
+ pp.stop()
+ if result:
+ self.guilogger.write("done.")
+ else:
+ self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+
+ def _download_file(self, file, target=None):
+ self.guilogger.write("Downloading %s to %s" % (file, target))
+ pp = PbarPulser(self.pbar)
+ pp.start()
+ result = self.worker.download_file(file, dest=target)
+ pp.stop()
+ if result:
+ self.guilogger.write("done.")
+ else:
+ self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ return result
+
def end_this_show(self):
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
@@ -306,6 +334,38 @@
self.logger.debug("Gui wrote log to disk")
self.gtk_main_quit()
+
+class PbarPulser(threading.Thread):
+ """Pulse the progressbar in a thread"""
+
+ #Thread event, stops the thread if it is set.
+ stopthread = threading.Event()
+
+ def __init__(self, pbar):
+ self.pbar = pbar
+ threading.Thread.__init__(self)
+
+ def run(self):
+ """Run method, this is the code that runs while thread is alive."""
+ self.pbar.show()
+ self.pbar.pulse()
+ #While the stopthread event isn't setted, the thread keeps going on
+ while not self.stopthread.isSet() :
+ # Acquiring the gtk global mutex
+ gtk.gdk.threads_enter()
+ #Setting a random value for the fraction
+ self.pbar.pulse()
+ # Releasing the gtk global mutex
+ gtk.gdk.threads_leave()
+ while gtk.events_pending():
+ gtk.mainiteration()
+ #Delaying 100ms until the next iteration
+ time.sleep(0.1)
+
+ def stop(self):
+ """Stop method, sets the event to terminate the thread's main loop"""
+ self.stopthread.set()
+
class LogDisplayer:
"""Wraps a TextView widget and sets the text in a seperate thread"""
def __init__(self, widget):
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-11-29 13:42:08 UTC (rev 3)
+++ glade/gui.ui 2009-12-02 14:14:04 UTC (rev 4)
@@ -63,7 +63,7 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label" translatable="yes">Rename Directory</property>
+ <property name="label" translatable="yes">Rename</property>
<property name="visible">True</property>
<property name="image">image6</property>
<property name="use_stock">False</property>
@@ -72,11 +72,11 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label" translatable="yes">Delete Directory</property>
+ <property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="image">image7</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_local_delete_directory_activated"/>
+ <signal name="activate" handler="on_local_delete_activated"/>
</object>
</child>
<child>
@@ -111,20 +111,20 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem11">
- <property name="label" translatable="yes">Rename Directory</property>
+ <property name="label" translatable="yes">Rename</property>
<property name="visible">True</property>
<property name="image">image10</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_rename_directory_activated"/>
+ <signal name="activate" handler="on_remote_rename_activated"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem12">
- <property name="label" translatable="yes">Delete Directory</property>
+ <property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="image">image11</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_delete_directory_activated"/>
+ <signal name="activate" handler="on_remote_delete_activated"/>
</object>
</child>
<child>
@@ -321,6 +321,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">300</property>
+ <property name="position_set">True</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
@@ -383,9 +384,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Upload the selected local files to the gmail account.
-Files will be stored with their complete path.
-You cannot upload them into a different remote directory.</property>
<signal name="clicked" handler="on_button_arrow_right_clicked"/>
<child>
<object class="GtkImage" id="image1">
@@ -405,11 +403,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Download the selected remote files to their original local paths.
-You can download them into a different directory by selecting
-one local directory. I there are multiple local directories
-selected the first will be used. When there's no local directory
-selected the original path from the remote file is used.</property>
<signal name="clicked" handler="on_button_arrow_left_clicked"/>
<child>
<object class="GtkImage" id="image2">
@@ -533,6 +526,33 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame_pbar">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_pbar">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_pbar">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
</child>
</object>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-12-02 14:14:16
|
Revision: 4
http://gbacker.svn.sourceforge.net/gbacker/?rev=4&view=rev
Author: stas_zytkiewicz
Date: 2009-12-02 14:14:04 +0000 (Wed, 02 Dec 2009)
Log Message:
-----------
More work on the gui part
Modified Paths:
--------------
Constants.py
FileBrowserWidget.py
GuiGtk.py
glade/gui.ui
Modified: Constants.py
===================================================================
--- Constants.py 2009-11-29 13:42:08 UTC (rev 3)
+++ Constants.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -1,12 +1,19 @@
# Constants used by gbacker
import os
-
+import sys
# Packagers, make sure to change the IBSIGRCPATH to the directory path
# where gbacker.rc is found.
# Further below we copy gbacker.rc into the users dir.
BASEIBSIGRCPATH = os.getcwd()
# Some constants
+if sys.platform == 'win32':
+ try:
+ ROOTPATH = os.environ['HOMEDRIVE']
+ except:
+ ROOTPATH = 'c:/'
+else:
+ ROOTPATH = '/'
HOMEDIR = os.path.expanduser('~')
APPNAME = 'gbacker'
LOGPATH = os.path.join(HOMEDIR,'.gbacker', APPNAME+".log")
Modified: FileBrowserWidget.py
===================================================================
--- FileBrowserWidget.py 2009-11-29 13:42:08 UTC (rev 3)
+++ FileBrowserWidget.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -48,9 +48,9 @@
'cursor-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
}
- def __init__(self, root=None):
+ def __init__(self, parent, root=None):
""" root is where we want the tree initialized """
-
+ self.parent = parent
gobject.GObject.__init__(self)
self.show_hidden = False
@@ -212,7 +212,7 @@
state = widget.get_active()
self.set_show_hidden(state)
-
+
#####################################################
# Directories and files, nodes and icons
@@ -393,8 +393,12 @@
self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files"))
self.hidden_check_menu.connect('toggled', self.show_hidden_toggled)
-
self.popup.add(self.hidden_check_menu)
+
+ self.delete_menu = gtk.MenuItem(_("Delete file"))
+ self.delete_menu.connect('activate', self.parent.delete_file, self)
+ self.popup.add(self.delete_menu)
+
self.popup.show_all()
@@ -511,31 +515,15 @@
This way we can use the TreeFileBrowser for directory like structures as
provided by gimap.
"""
- def __init__(self, root=None):
+ def __init__(self,parent, root=None):
"""@account must be a gimap.ImapAccount instance on which the login method
is called.
As a reminder we override the standard Python modules os and os.path.
Only the following os and os.path methods are provided:
os.listdir, os.path.join and os.path.isdir.
"""
- TreeFileBrowser.__init__(self, root)
+ TreeFileBrowser.__init__(self, parent, root)
- def get_selected(self):
- """ Returns selected item(s) in browser """
- if not self.multiple_selection:
- model, iter = self.view.get_selection().get_selected()
- if iter != None:
- return model.get_value(iter, 2)
- else:
- return None
- else:
- model, selected = self.view.get_selection().get_selected_rows()
- if selected != None:
- ls = []
- iters = [model.get_iter(path) for path in selected]
- for iter in iters:
- ls.append(model.get_value(iter, 2))
- return ls
if __name__ == "__main__":
from gettext import gettext as _
Modified: GuiGtk.py
===================================================================
--- GuiGtk.py 2009-11-29 13:42:08 UTC (rev 3)
+++ GuiGtk.py 2009-12-02 14:14:04 UTC (rev 4)
@@ -23,6 +23,8 @@
import sys
import logging
import glob
+import time
+import threading
module_logger = logging.getLogger('gbacker.GuiGtk')
@@ -46,6 +48,9 @@
except ImportError:
module_logger.error("No pango package found, stopping.")
sys.exit(1)
+
+#Initializing the gtk's thread engine
+gtk.gdk.threads_init
import gobject
import time
@@ -91,11 +96,16 @@
self.guilogger = LogDisplayer(self.textview1)# wraps the textview
self.guilogger.write("Start logger")
# add the treebrowser widget
- self.local_tree_widget = TreeFileBrowser(os.path.expanduser('~'))
+ self.local_tree_widget = TreeFileBrowser(self, os.path.expanduser('~'))
self.alignment_local.add(self.local_tree_widget.scrolled)
# the remote treebrowser widget is added in on_button_connect_clicked
+ self.remote_tree_widget = None
self.window1.show_all()
-
+ # setup our threaded progressbar
+ self.pbar = gtk.ProgressBar()
+ self.pbar.set_pulse_step(0.1)
+ self.alignment_pbar.add(self.pbar)
+
def on_window1_delete_event(self, widget, *args):
self.logger.debug('on_window1_delete_event called with self.%s' % widget.get_name())
# placeholder: 'do you want to quit' dialog
@@ -112,12 +122,12 @@
self.logger.debug('on_local_new_directory_activated called with self.%s' % widget.get_name())
return True
- def on_local_rename_directory_activated(self, widget, *args):
- self.logger.debug('on_local_rename_directory_activated called with self.%s' % widget.get_name())
+ def on_local_rename_activated(self, widget, *args):
+ self.logger.debug('on_local_rename_activated called with self.%s' % widget.get_name())
return True
- def on_local_delete_directory_activated(self, widget, *args):
- self.logger.debug('on_local_delete_directory_activated called with self.%s' % widget.get_name())
+ def on_local_delete_activated(self, widget, *args):
+ self.logger.debug('on_local_delete_activated called with self.%s' % widget.get_name())
return True
def on_local_upload_directory_activated(self, widget, *args):
@@ -128,12 +138,12 @@
self.logger.debug('on_remote_new_directory_activated called with self.%s' % widget.get_name())
return True
- def on_remote_rename_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_rename_directory_activated called with self.%s' % widget.get_name())
+ def on_remote_rename_activated(self, widget, *args):
+ self.logger.debug('on_remote_rename_activated called with self.%s' % widget.get_name())
return True
- def on_remote_delete_directory_activated(self, widget, *args):
- self.logger.debug('on_remote_delete_directory_activated called with self.%s' % widget.get_name())
+ def on_remote_delete_activated(self, widget, *args):
+ self.logger.debug('on_remote_delete_activated called with self.%s' % widget.get_name())
return True
def on_remote_download_directory_activated(self, widget, *args):
@@ -187,7 +197,7 @@
self.connected = True
# add the remote treebrowser widget
# The first part of the emptytree is stripped from the view
- self.remote_tree_widget = RemoteTreeFileBrowser(os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
+ self.remote_tree_widget = RemoteTreeFileBrowser(self, os.path.join(TEMPDIR, account, os.path.expanduser('~')[1:]))
self.alignment_remote.add(self.remote_tree_widget.scrolled)
self.alignment_remote.show_all()
return True
@@ -202,7 +212,8 @@
self.button_disconnect.set_sensitive(False)
self.button_connect.set_sensitive(True)
self.connected = False
- self.remote_tree_widget.view.hide()
+ if self.remote_tree_widget:
+ self.remote_tree_widget.view.hide()
return True
def on_button_arrow_right_clicked(self, widget, *args):
@@ -219,16 +230,15 @@
return True
else:
self.guilogger.write("%s files selected, starting to upload" % len(selectedfiles))
+
+ self.frame_pbar.show_all()
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
- self.guilogger.write("Uploading %s" % file)
- self.worker.upload_file(file)
- self.guilogger.write("done.")
+ self._upload_file(file)
else:
- self.guilogger.write("Uploading %s" % item)
- self.worker.upload_file(item)
- self.guilogger.write("done.")
+ self._upload_file(item)
+ self.frame_pbar.hide()
return True
def on_button_arrow_left_clicked(self, widget, *args):
@@ -240,7 +250,7 @@
return
targetdirectory = self.local_tree_widget.get_selected()
if not targetdirectory:
- target = os.path.expanduser('~')
+ target = os.path.expanduser(ROOTPATH)
else:
for path in targetdirectory:
if os.path.isdir(path):
@@ -257,17 +267,9 @@
for item in selectedfiles:
if os.path.isdir(item):
for file in glob.glob(os.path.join(item, '*')):
- self.guilogger.write("Downloading %s to %s" % (file, target))
- if self.worker.download_file(file, dest=target):
- self.guilogger.write("done.")
- else:
- self.guilogger.write("failed")
+ self._download_file(file, target)
else:
- self.guilogger.write("Downloading %s to %s" % (item, target))
- if self.worker.download_file(item, dest=target):
- self.guilogger.write("done.")
- else:
- self.guilogger.write("failed")
+ self._download_file(item, target)
return True
###### Non-glade callbacks ############
@@ -283,10 +285,36 @@
self.accountname = combobox.get_text()
model.insert(0, [self.accountname])
self.comboboxentry_account.set_active(0)
+
+ def delete_file(self, widget, tree):
+ """Callback for the popup menu item 'delete file' in the TreeFileBrowser"""
+ print "delete_file", tree.get_selected()
-
######## Various internally used methods ############
-
+
+ def _upload_file(self, file):
+ self.guilogger.write("Uploading %s" % file)
+ pp = PbarPulser(self.pbar)
+ pp.start()
+ result = self.worker.upload_file(file)
+ pp.stop()
+ if result:
+ self.guilogger.write("done.")
+ else:
+ self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+
+ def _download_file(self, file, target=None):
+ self.guilogger.write("Downloading %s to %s" % (file, target))
+ pp = PbarPulser(self.pbar)
+ pp.start()
+ result = self.worker.download_file(file, dest=target)
+ pp.stop()
+ if result:
+ self.guilogger.write("done.")
+ else:
+ self.guilogger.write("failed, check the logs in %s." % LOGPATH)
+ return result
+
def end_this_show(self):
"""Stop GUI stuff and cleanup"""
self.on_button_disconnect_clicked(None)
@@ -306,6 +334,38 @@
self.logger.debug("Gui wrote log to disk")
self.gtk_main_quit()
+
+class PbarPulser(threading.Thread):
+ """Pulse the progressbar in a thread"""
+
+ #Thread event, stops the thread if it is set.
+ stopthread = threading.Event()
+
+ def __init__(self, pbar):
+ self.pbar = pbar
+ threading.Thread.__init__(self)
+
+ def run(self):
+ """Run method, this is the code that runs while thread is alive."""
+ self.pbar.show()
+ self.pbar.pulse()
+ #While the stopthread event isn't setted, the thread keeps going on
+ while not self.stopthread.isSet() :
+ # Acquiring the gtk global mutex
+ gtk.gdk.threads_enter()
+ #Setting a random value for the fraction
+ self.pbar.pulse()
+ # Releasing the gtk global mutex
+ gtk.gdk.threads_leave()
+ while gtk.events_pending():
+ gtk.mainiteration()
+ #Delaying 100ms until the next iteration
+ time.sleep(0.1)
+
+ def stop(self):
+ """Stop method, sets the event to terminate the thread's main loop"""
+ self.stopthread.set()
+
class LogDisplayer:
"""Wraps a TextView widget and sets the text in a seperate thread"""
def __init__(self, widget):
Modified: glade/gui.ui
===================================================================
--- glade/gui.ui 2009-11-29 13:42:08 UTC (rev 3)
+++ glade/gui.ui 2009-12-02 14:14:04 UTC (rev 4)
@@ -63,7 +63,7 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label" translatable="yes">Rename Directory</property>
+ <property name="label" translatable="yes">Rename</property>
<property name="visible">True</property>
<property name="image">image6</property>
<property name="use_stock">False</property>
@@ -72,11 +72,11 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label" translatable="yes">Delete Directory</property>
+ <property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="image">image7</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_local_delete_directory_activated"/>
+ <signal name="activate" handler="on_local_delete_activated"/>
</object>
</child>
<child>
@@ -111,20 +111,20 @@
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem11">
- <property name="label" translatable="yes">Rename Directory</property>
+ <property name="label" translatable="yes">Rename</property>
<property name="visible">True</property>
<property name="image">image10</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_rename_directory_activated"/>
+ <signal name="activate" handler="on_remote_rename_activated"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem12">
- <property name="label" translatable="yes">Delete Directory</property>
+ <property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="image">image11</property>
<property name="use_stock">False</property>
- <signal name="activate" handler="on_remote_delete_directory_activated"/>
+ <signal name="activate" handler="on_remote_delete_activated"/>
</object>
</child>
<child>
@@ -321,6 +321,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">300</property>
+ <property name="position_set">True</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
@@ -383,9 +384,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Upload the selected local files to the gmail account.
-Files will be stored with their complete path.
-You cannot upload them into a different remote directory.</property>
<signal name="clicked" handler="on_button_arrow_right_clicked"/>
<child>
<object class="GtkImage" id="image1">
@@ -405,11 +403,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Download the selected remote files to their original local paths.
-You can download them into a different directory by selecting
-one local directory. I there are multiple local directories
-selected the first will be used. When there's no local directory
-selected the original path from the remote file is used.</property>
<signal name="clicked" handler="on_button_arrow_left_clicked"/>
<child>
<object class="GtkImage" id="image2">
@@ -533,6 +526,33 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame_pbar">
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment_pbar">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_pbar">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Uploading/Downloading</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
</child>
</object>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sta...@us...> - 2009-11-29 13:42:19
|
Revision: 3
http://gbacker.svn.sourceforge.net/gbacker/?rev=3&view=rev
Author: stas_zytkiewicz
Date: 2009-11-29 13:42:08 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Added some text
Modified Paths:
--------------
README.message_format
Modified: README.message_format
===================================================================
--- README.message_format 2009-11-29 13:14:15 UTC (rev 2)
+++ README.message_format 2009-11-29 13:42:08 UTC (rev 3)
@@ -0,0 +1,20 @@
+The message format used by gbacker is as follows.
+
+The subject line consists of the full path of the parent
+directory, the full file path and the ID from the database.
+The parts are seperated by two #
+For example: "/home/stas/test##/home/stas/test/foo.py##ID86"
+
+The body of message contains various lines;
+
+"path: <full path of the file>"
+"creation: <creation date of the file>"
+"size: <size in KB>"
+"up_load: <upload date>"
+"encrypt: <Boolean, if the attachement is encrypted>"
+"current_dir: <parent directory>"
+"tag: <misc text>"
+"id: <dbase id>"
+"account: <account name>"
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|