Exemplo n.º 1
0
 def __init__(self):
     '''
     should only be called by the manager
     '''
     Pyro4.config.HMAC_KEY = config().sharedKey
     Pyro4.config.HOST = config().publicAddress
     self.isNameserver = False
     self.address = config().publicAddress
     self.services = []
     self.enshureNameserver()
     self.registerService(Manager(), 'manager.' + config().servicename)
     logger.info('Pyro-Server ready!')
Exemplo n.º 2
0
    def __init__(self):
        '''
        Constructor
        '''
        self.cachePath = config().cachePath
        self.writeSemaphore = Semaphore()

        self.verify()
Exemplo n.º 3
0
 def __init__(self):
     '''
     There must only be one Hasher at Time.
     '''
     self.toHash = Queue()
     for i in range(config().workerThreads):
         self.hashWorker = Thread(target=self.createHashWorker)
         self.hashWorker.daemon = True
         self.hashWorker.name = 'Hash Worker #' + str(i)
         self.hashWorker.start()
Exemplo n.º 4
0
 def startNameserver(hostname):
     logger.info('Starting local Nameserver on ' + hostname)
     nameserverUri, nameserverDaemon, broadcastServer = Pyro4.naming.startNS(hostname)
     logger.debug('Nameserver running on ' + str(nameserverUri))
     while not config().stopEvent.is_set():
         nameserverSockets = set(nameserverDaemon.sockets)
         rs = [broadcastServer]  # only the broadcast server is directly usable as a select() object
         rs.extend(nameserverSockets)
         rs, _, _ = select.select(rs, [], [], 3)
         eventsForNameserver = []
         for s in rs:
             if s is broadcastServer:
                 #logger.debug('Broadcast server received a request')
                 broadcastServer.processRequest()
             elif s in nameserverSockets:
                 eventsForNameserver.append(s)
         if eventsForNameserver:
             #logger.debug('Nameserver received a request')
             nameserverDaemon.events(eventsForNameserver)
Exemplo n.º 5
0
 def close(self):
     logger.info('Closing server on ' + self.address)
     self.nameserver.remove(regex='.*\.' + config().servicename)
     self.nameserver.remove('manager.' + config().servicename)
     if self.isNameserver:
         del(self.nameserverThread)
Exemplo n.º 6
0
 def __init__(self):
     Pyro4.config.HMAC_KEY = config().sharedKey
     self.nameserver = Pyro4.naming.locateNS()
     self.knownExports = dict()
Exemplo n.º 7
0
    def __init__(self, path, name):

        self.exportName = 'export.' + name + '.' + config().servicename
        logger.info('Creating remote interface for: ' + path)
        self.export = Export(path, self.exportName)
        logger.info('Remote Interface for: ' + path + ' will be exposed on ' + str(self.export.getRootUri()))
Exemplo n.º 8
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
Exemplo n.º 9
0
 def isLocal(self):
     return self.exportIdentifier.split('.')[-1] == config().servicename
Exemplo n.º 10
0
def main():

    parser = argparse.ArgumentParser(prog="Wolpertinger", description="Start a wolpertinger server.")
    parser.add_argument("--loglevel", dest="loglevel", default="INFO", help="DEBUG, INFO, WARNING or ERROR")
    parser.add_argument(
        "--logfile", dest="logfile", default="wolpertinger.log", help="typically /var/log/wolpertinger.log"
    )
    parser.add_argument(
        "--configfile",
        dest="configfile",
        default="wolpertinger.conf",
        help="check wolpertinger.conf.example for reference",
    )

    args = parser.parse_args()

    if args.loglevel.upper() == "DEBUG":
        config().loglevel = "DEBUG"
    elif args.loglevel.upper() == "INFO":
        config().loglevel = "INFO"
    elif args.loglevel.upper() == "WARNING":
        config().loglevel = "WARNING"
    elif args.loglevel.upper() == "ERROR":
        config().loglevel = "ERROR"

    config().logfile = args.logfile

    startLogger()

    config().registerComMethodes()

    for key in config().exposedFolders.keys():
        server().add(config().exposedFolders[key], key)
    while False == config().stopEvent.is_set():
        if "quit" == input("#:"):
            config().stopEvent.set()
            server().close()
Exemplo n.º 11
0
 def testGetExposedFolders(self):
     config().exposedFolders