Exemplo n.º 1
0
 def sync(self, source, target, dryRun=True):
     '''
     finds all differences between source and target
     '''
     sourceFolder = client().get(source)
     targetFolder = client().get(target)
     transportList = sourceFolder.sync(targetFolder)
     if False == dryRun:
         agent().add(transportList)
     return transportList
Exemplo n.º 2
0
 def add(self, transferList):
     '''
     transferList is a list of tuple: (SourceUri, TargetUri)
     '''
     for transfer in transferList:
         sourceItem = client().get(transfer[0])
         targetItem = client().get(transfer[1])
         if sourceItem.uri.isLocal and targetItem.uri.isLocal:
             copyAgent().add(sourceItem.path, targetItem.path)
         else:
             raise NotImplementedError()
Exemplo n.º 3
0
def main(argv=None):
    '''Command line options.'''

    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    program_name = os.path.basename(sys.argv[0])
    program_version = "v%s" % __version__
    program_build_date = str(__updated__)
    program_version_message = '%%(prog)s %s (%s)' % (program_version, program_build_date)
    program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
    program_license = '''%s

Copyright (C) 2012-2013 Konstantin Renner

Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

%s

USAGE
''' % (program_shortdesc, str(__date__))

    try:
        # Setup argument parser
        parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
        #parser.add_argument("-r", "--recursive", dest="recurse", action="store_true", help="recurse into subfolders [default: %(default)s]")
        #parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
        parser.add_argument('--target', dest="target", help='the target for the sync command.')
        parser.add_argument('--source', dest="source", help='the source for the sync command.\n\
                                                        can also be used with the list command to search a directory')
        parser.add_argument('-V', '--version', action='version', version=program_version_message)
        parser.add_argument(dest='command', help='list, sync', choices=['list', 'sync'])
        # Process arguments
        args = parser.parse_args()

        command = args.command
        source = args.source
        target = args.target

        config().registerComMethodes()

        if 'list' == command and None == source:
            print('Exports found:')
            for export in client().listExports():
                print('WT://' + export + '/')
        elif 'list' == command:
            for item in client().get(source).items.items():
                print(item[1].uri)
        elif 'sync' == command:
            print('Trying to sync:' + source + ' to ' + target)

    except KeyboardInterrupt:
        ### handle keyboard interrupt ###
        return 0

    except Exception as e:
        if DEBUG or TESTRUN:
            raise(e)
        indent = len(program_name) * " "
        sys.stderr.write(program_name + ": " + repr(e) + "\n")
        sys.stderr.write(indent + "  for help use --help")
        return 2