コード例 #1
0
ファイル: templates.py プロジェクト: emin63/dibs
    def run(self, argv=None, parentWindow=None):
        """
        run(self,argv=None):

        argv:  Either None or an argv list indicated the arguments for
               this command as a list of strings with argv[0] being the
               program name.  If argv is not None, then the
               ParseRequiredArgs function should be called to parse argv,
               otherwise, the values of self.argDict[...] should already
               have been set (e.g., by the GUI).

        parentWindow:  Either None or a window from Tkinter indicating
                       the parent window of this command if this command
                       was invoked from the GUI.

        A command's run method should first call the PrepareForDIBSCommand
        function, then implement the desired functions, and finally call
        FinishDIBSCommand.  The return value should either be None or
        a string describing the result of running the command.  Any such
        strings returned will be displayed in a dialog box by the GUI.
        """
        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        import dibs_main
        d = dibs_main.DIBS(self.database)

        # do whatever you like here
        result = 'Generic command called.'

        self.FinishDIBSCommand()

        return result
コード例 #2
0
    def run(self,argv=None,parentWindow=None):
        self.PrepareForDIBSCommand()

        if (None != argv):
            self.ParseRequiredArgs(argv)
            
        self.WarnAboutLocalhostHostIfNecessary()
        import dibs_main
        d = dibs_main.DIBS(self.database)

        d.ProposePeerContract(
            self['contract_name'],self['local_quota'],self['remote_quota'],
            self['talk'],self['listen'],self['host'],self['peer'],
            self['peer_host'],self['peer_port'],self['peer_email'],self['url'])

        if (str == type(self['auto_poll'])):
            self['auto_poll'] = self['auto_poll'].strip().lower()
        if (not ['','0','no',None,0].count(self['auto_poll'])):
            time.sleep(2)
            import communication_commands
            communication_commands.PollPassivesCmd('poll_passives').run(
                ['fake'])
            communication_commands.ProcessMessageCmd('process_message').run(
                ['fake'])

            
        self.FinishDIBSCommand()
コード例 #3
0
    def run(self, argv=None, parentWindow=None):
        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        import dibs_main
        d = dibs_main.DIBS(self.database)
        d.Cleanup()

        self.FinishDIBSCommand()
コード例 #4
0
    def run(self,argv=None,parentWindow=None):
        self.PrepareForDIBSCommand()

        if (None != argv):
            self.ParseRequiredArgs(argv)

        import dibs_main
        d = dibs_main.DIBS(self.database)
        if (None == self['url'] or '' == self['url'].strip()):
            self['url'] = dibs_options.defaultContractServerURL
        d.UnpostPeerContract(self['contract_name'],self['url'])

        self.FinishDIBSCommand()
コード例 #5
0
ファイル: storage_commands.py プロジェクト: emin63/dibs
    def run(self, argv=None, parentWindow=None):
        self.PrepareForDIBSCommand()

        if (None != argv):
            self.ParseRequiredArgs(argv)

        import dibs_main
        d = dibs_main.DIBS(self.database)
        dir = dibs_options.autoBackupDir
        for file in os.listdir(dir):
            d.StoreAsNecessary(
                os.path.abspath(PathJoin(dir, file)),
                PathJoin(dibs_options.rootDir + 'autoBackup', file))
            d.SendOutgoingMessages()

        self.FinishDIBSCommand()
コード例 #6
0
ファイル: storage_commands.py プロジェクト: emin63/dibs
    def run(self, argv=None, parentWindow=None):

        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        self['name'] = os.path.abspath(self['name'])
        if (None == self['as'] or '' == self['as']):
            self['as'] = self['name']

        import dibs_main
        d = dibs_main.DIBS(self.database)
        d.StoreAsNecessary(self['name'], self['as'])
        d.SendOutgoingMessages()

        self.FinishDIBSCommand()
コード例 #7
0
    def run(self, argv=None, parentWindow=None):

        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        import dibs_main
        d = dibs_main.DIBS(self.database)
        global gFileToMoveOnError
        for file in os.listdir(dibs_options.statsMsgDir):
            fullFileName = PathJoin(dibs_options.statsMsgDir, file)
            gFileToMoveOnError = fullFileName
            d.database.statsDatabase.ImportFromFile(fullFileName)
            os.remove(fullFileName)

        self.FinishDIBSCommand()
コード例 #8
0
    def run(self,argv=None,parentWindow=None):

        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        import dibs_main
        d = dibs_main.DIBS(self.database)

        ComplainAboutBadPeerOptions(self['email'],self['peer'],
                                    self['remote_quota'],
                                    self['local_quota'],self['comment'],
                                    self['talk'],self['listen'],
                                    self['host'],self['port'])
        d.database.EditPeer(self['email'],self['peer'],self['remote_quota'],
                            self['local_quota'],self['comment'],
                            self['talk'],self['listen'],self['host']
                            ,self['port'])

        self.FinishDIBSCommand()
コード例 #9
0
    def run(self, argv=None, parentWindow=None):
        self.PrepareForDIBSCommand()

        if (None != argv):
            self.ParseRequiredArgs(argv)

        import dibs_main
        d = dibs_main.DIBS(self.database)

        if (None == self['only'] or '' == self['only'].strip()):
            result = d.database.__str__()
        elif (self.onlyOptionsMapping.has_key(self['only'])):
            result = self.onlyOptionsMapping[self['only']](d)()
        else:
            msg = ('Unknown option for --only : "' + self['only'] + '".' +
                   '\nPossible values are ' + ` onlyOptionsMapping.keys() `)
            raise Exception, msg

        self.FinishDIBSCommand()

        return result
コード例 #10
0
    def run(self,argv=None,parentWindow=None):

        self.PrepareForDIBSCommand()
        
        if (None != argv):
            self.ParseRequiredArgs(argv)
        self.WarnAboutLocalhostHostIfNecessary()
        if (not self['port']):
            self['port'] = dibs_options.daemonPort
        self.ComplainAboutMissingRequiredArguments()

        import dibs_main
        d = dibs_main.DIBS(self.database)
        if (not self['url']):
            self['url'] = dibs_options.defaultContractServerURL
        d.PostPeerContract(self['host'],self['port'],
                           self['talk'],self['listen'],
                           self['min_quota'],self['max_quota'],
                           self['quota_mult'],self['lifetime'],
                           self['contract_name'],self['url'])

        self.FinishDIBSCommand()
コード例 #11
0
    def run(self, argv=None, parentWindow=None):

        if (None != argv):
            self.ParseRequiredArgs(argv)

        self.PrepareForDIBSCommand()

        import dibs_main
        d = dibs_main.DIBS(self.database)

        if (None == self['file']):
            self['file'] = ''
        if (not self['file'] and d.database.NumStoredFiles() > 0):
            d.PrintAndLog('Cleaning out stale probes.')
            d.database.CloseOldProbes()
            fileName = d.database.GetRandomStoredFilename()
            d.PrintAndLog('Probing random file ' + ` fileName `)
            d.ProbeFile(fileName)
        else:
            d.ProbeFile(self['file'])
            d.PrintAndLog('Sending probe requests for file ' + self['file'] +
                          '.')

        self.FinishDIBSCommand()