/head: changeset 113
Added support for command-line arguments
This commit is contained in:
		| @@ -1,8 +1,17 @@ | ||||
| offlineimap (3.0.0) unstable; urgency=low | ||||
|  | ||||
|   * Introduced a new graphical user interface written with Tkinter. | ||||
|     It features a nice view of multi-threaded displays. | ||||
|   * Made IMAP folder addmessagesflags() resiliant to a server refusing | ||||
|     to return a full set of new message flags.  Closes: #152587. | ||||
|   * Completely rewrote documentation.  OfflineIMAP now has an | ||||
|     exhaustive manpage, which is really a manual.  It is also shipped | ||||
|     in plain text, HTML, PDF, and PostScript formats. | ||||
|   * New command-line options: | ||||
|     -1 to force no multi-threaded operation | ||||
|     -u to force a particular UI | ||||
|     -a to specify which accounts to sync | ||||
|     -h to print help | ||||
|  | ||||
|  -- John Goerzen <jgoerzen@complete.org>  Thu, 11 Jul 2002 08:35:42 -0500 | ||||
|  | ||||
|   | ||||
| @@ -1,2 +1,5 @@ | ||||
| README | ||||
| offlineimap.conf | ||||
| manual.txt | ||||
| manual.ps | ||||
| manual.pdf | ||||
| manual.html | ||||
|  | ||||
|   | ||||
| @@ -81,7 +81,7 @@ binary-indep: build install | ||||
| #	dh_installmime | ||||
| 	dh_installinit | ||||
| 	dh_installcron | ||||
| 	dh_installman | ||||
| 	dh_installman offlineimap.1 | ||||
| 	dh_installinfo | ||||
| #	dh_undocumented | ||||
| 	dh_installchangelogs  | ||||
|   | ||||
| @@ -17,25 +17,43 @@ | ||||
| #    along with this program; if not, write to the Free Software | ||||
| #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
|  | ||||
| from offlineimap import imaplib, imaputil, imapserver, repository, folder, mbnames, threadutil | ||||
| from offlineimap import imaplib, imaputil, imapserver, repository, folder, mbnames, threadutil, version | ||||
| from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread | ||||
| import re, os, os.path, offlineimap, sys | ||||
| from ConfigParser import ConfigParser | ||||
| from threading import * | ||||
| from getopt import getopt | ||||
|  | ||||
| options = {} | ||||
| if '--help' in sys.argv[1:]: | ||||
|     sys.stdout.write(version.cmdhelp + "\n") | ||||
|     sys.exit(0) | ||||
|      | ||||
| for optlist in getopt(sys.argv[1:], '1a:c:du:h')[0]: | ||||
|     options[optlist[0]] = optlist[1] | ||||
|  | ||||
| if '-d' in sys.argv: | ||||
| if '-d' in options: | ||||
|     imaplib.Debug = 5 | ||||
| if '-h' in options: | ||||
|     sys.stdout.write(version.cmdhelp) | ||||
|     sys.stdout.write("\n") | ||||
|     sys.exit(0) | ||||
| configfilename = os.path.expanduser("~/.offlineimaprc") | ||||
| if '-c' in options: | ||||
|     configfilename = options['-c'] | ||||
|  | ||||
|  | ||||
| config = ConfigParser() | ||||
| configfilename = os.path.expanduser("~/.offlineimaprc") | ||||
| if not os.path.exists(configfilename): | ||||
|     sys.stderr.write(" *** Config file %s does not exist; aborting!\n" % configfilename) | ||||
|     sys.exit(1) | ||||
|      | ||||
| config.read(configfilename) | ||||
|  | ||||
| ui = offlineimap.ui.detector.findUI(config) | ||||
| if '-u' in options: | ||||
|     ui = offlineimap.ui.detector.getUImod(options['-u'])() | ||||
| else: | ||||
|     ui = offlineimap.ui.detector.findUI(config) | ||||
| ui.init_banner() | ||||
|  | ||||
|  | ||||
| @@ -44,6 +62,8 @@ if not os.path.exists(metadatadir): | ||||
|     os.mkdir(metadatadir, 0700) | ||||
|  | ||||
| accounts = config.get("general", "accounts") | ||||
| if '-a' in options: | ||||
|     accounts = options['-a'] | ||||
| accounts = accounts.replace(" ", "") | ||||
| accounts = accounts.split(",") | ||||
|  | ||||
| @@ -53,8 +73,11 @@ localrepos = None | ||||
| passwords = {} | ||||
| tunnels = {} | ||||
|  | ||||
| threadutil.initInstanceLimit("ACCOUNTLIMIT", config.getint("general", | ||||
|                                                            "maxsyncaccounts")) | ||||
| if '-1' in options: | ||||
|     threadutil.initInstanceLimit("ACCOUNTLIMIT", 1) | ||||
| else: | ||||
|     threadutil.initInstanceLimit("ACCOUNTLIMIT", | ||||
|                                  config.getint("general", "maxsyncaccounts")) | ||||
|  | ||||
| # We have to gather passwords here -- don't want to have two threads | ||||
| # asking for passwords simultaneously. | ||||
| @@ -71,8 +94,11 @@ for account in accounts: | ||||
|     else: | ||||
|         passwords[account] = ui.getpass(account, config) | ||||
|     for instancename in ["FOLDER_" + account, "MSGCOPY_" + account]: | ||||
|         threadutil.initInstanceLimit(instancename, | ||||
|                                      config.getint(account, "maxconnections")) | ||||
|         if '-1' in options: | ||||
|             threadutil.initInstanceLimit(instancename, 1) | ||||
|         else: | ||||
|             threadutil.initInstanceLimit(instancename, | ||||
|                                          config.getint(account, "maxconnections")) | ||||
|  | ||||
| mailboxes = [] | ||||
| mailboxlock = Lock() | ||||
|   | ||||
| @@ -33,3 +33,48 @@ GNU General Public License for more details. | ||||
| You should have received a copy of the GNU General Public License | ||||
| along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA""" | ||||
|  | ||||
| cmdhelp = """ | ||||
|        offlineimap [ -1 ] [ -a accountlist ] [ -c configfile ] | ||||
|        [ -d ] [ -u interface ] | ||||
|  | ||||
|        offlineimap -h | --help | ||||
|  | ||||
|        -1     Disable   all  multithreading  operations  and  use | ||||
|               solely a single-thread sync.  This effectively sets | ||||
|               the maxsyncaccounts and all maxconnections configu- | ||||
|               ration file variables to 1. | ||||
|  | ||||
|        -a accountlist | ||||
|               Overrides the accounts section in the config  file. | ||||
|               Lets  you  specify  a  particular account or set of | ||||
|               accounts to sync without having to edit the  config | ||||
|               file.   You  might  use  this  to  exclude  certain | ||||
|               accounts, or to sync some accounts  that  you  nor- | ||||
|               mally prefer not to. | ||||
|  | ||||
|        -c configfile | ||||
|               Specifies  a  configuration  file to use in lieu of | ||||
|               the default, ~/.offlineimaprc. | ||||
|  | ||||
|        -d     Enables IMAP protocol stream and parsing debugging. | ||||
|               This  is  useful  if you are trying to track down a | ||||
|               malfunction or figure out what is  going  on  under | ||||
|               the  hood.   I suggest that you use this with -1 in | ||||
|               order to make the results more sensible.  Note that | ||||
|               this  output  will  contain  full  IMAP protocol in | ||||
|               plain text, including passwords, so  take  care  to | ||||
|               remove  that from the debugging output before send- | ||||
|               ing it to anyone else. | ||||
|  | ||||
|        -h, --help | ||||
|               Show summary of options. | ||||
|  | ||||
|        -u interface | ||||
|               Specifies an alternative user interface  module  to | ||||
|               use.   This  overrides the default specified in the | ||||
|               configuration file.  The UI specified with -u  will | ||||
|               be  forced to be used, even if its isuable() method | ||||
|               states that it cannot be.   Use  this  option  with | ||||
|               care. | ||||
| """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jgoerzen
					jgoerzen