import repository from arizona
[raven.git] / apps / stork / storkreposync.py
1 #! /usr/bin/env python
2 """
3 <Program Name>
4    storkreposync.py
5
6 <Started>
7    5-6-09
8
9 <Author>
10    Programmed by .
11
12 <Purpose>
13    Command-line front end for synchronizing with repositories. This is basically
14    a wrapper around storkrepodl.py.
15 """
16
17 #           [option, long option,    variable,     action,        data,     default,                            metavar, description]
18 """arizonaconfig
19    options=[
20             ["-C",   "--configfile", "configfile", "store",       "string", "/usr/local/stork/etc/stork.conf", "FILE",   "use a different config file (/usr/local/stork/etc/stork.conf is the default)"],
21             ["",     "--mask",       "mask",       "store",       "string", None, "MASK", "specify mask of files to download"],
22             ["",     "--timeoutput", "timeoutput", "store_true",  None,     False,                              None,    "timestamp each line of output with time since start"],
23             ["",     "--heapoutput", "heapoutput", "store_true",  None,     False,                              None,    "heapstamp each line of output with current heap usage since start"]]
24
25    includes=[]
26 """
27
28 import os
29 import sys
30 import tempfile
31 import arizonageneral
32 import shutil
33 import arizonaconfig
34 import arizonacrypt
35 import arizonareport
36 import arizonatransfer
37 import dircache
38 import random
39 import fnmatch
40 import storkerror
41 import storkoutputfuncs
42 import storkrepodl
43 import storkrepolist
44 import storkversion
45
46 def main(args):
47    """ TODO comment """
48
49    mask = arizonaconfig.get_option("mask")
50    if mask:
51        maskList = [mask]
52    else:
53        maskList = []
54
55    storkrepodl.sync(False, maskList)
56
57 if __name__ == "__main__":
58    try:
59       # use error reporting tool
60       storkerror.init_error_reporting("stork.py")
61
62       # get command line and config file options
63       args = arizonaconfig.init_options("storkreposync.py", configfile_optvar="configfile", version=storkversion.VERREL)
64
65       if arizonaconfig.get_option("timeoutput"):
66           storkoutputfuncs.enable_timestamp_output()
67
68       if arizonaconfig.get_option("heapoutput"):
69           storkoutputfuncs.enable_heapstamp_output()
70
71       if os.geteuid() > 0:
72           arizonareport.send_error(0, "You must be root to run this program...")
73           sys.exit(1)
74
75       main(args)
76    except KeyboardInterrupt:
77       arizonareport.send_out(0, "Exiting via keyboard interrupt...")
78       sys.exit(0)