Ejemplo n.º 1
0
def main():
    '''Function to invoke this application.'''
    # Get host and port.
    connection_details = {}
    connection_details['host'] = raw_input('Enter host: ')
    port_text = raw_input('Enter port (default is 6884): ')
    if port_text:
        connection_details['port'] = int(port_text)

    # Username and password.
    username = raw_input('Enter user name (leave blank if not applicable): ')
    password = None
    if username:
        import getpass

        connection_details['user'] = username
        connection_details['password'] = getpass.getpass('Enter password: ')

    my_locals = {}
    from dopal.main import make_connection

    connection = make_connection(**connection_details)
    connection.is_persistent_connection = True

    from dopal.errors import LinkError

    try:
        interface = connection.get_plugin_interface()
    except LinkError, error:
        interface = None
        connection_error = error
Ejemplo n.º 2
0
def main():
    '''Function to invoke this application.'''
    # Get host and port.
    connection_details = {}
    connection_details['host'] = raw_input('Enter host (default is 127.0.0.1): ')
    if connection_details['host']=="":
        connection_details['host'] = '127.0.0.1'

    port_text = raw_input('Enter port (default is 6884): ')
    if port_text:
        connection_details['port'] = int(port_text)

    # Username and password.
    username = raw_input('Enter user name (leave blank if not applicable): ')
    password = None
    if username:
        import getpass
        connection_details['user'] = username
        connection_details['password'] = getpass.getpass('Enter password: ')

    my_locals = {}
    from dopal.main import make_connection
    connection = make_connection(**connection_details)
    connection.is_persistent_connection = True

    from dopal.errors import LinkError
    try:
        interface = connection.get_plugin_interface()
    except LinkError, error:
        interface = None
        connection_error = error
Ejemplo n.º 3
0
    def initialize(self):

        # flu

        # check dirs
        if not self.checkDirs():
            self.logger.error("Error checking dirs. path: %s" % self.tf_path)
            return False

        # delete command-file if exists
        if os.path.isfile(self.flu_fileCommand):
            try:
                self.logger.info("removing command-file %s ..." % self.flu_fileCommand)
                os.remove(self.flu_fileCommand)
            except:
                self.logger.error("Failed to delete commandfile %s" % self.flu_fileCommand)
                return False

        # load transfers
        self.loadTransfers()

        # azu
        self.logger.info("connecting to Azureus-Server (%s:%d)..." % (self.azu_host, self.azu_port))

        # set connection details
        connection_details = {}
        connection_details['host'] = self.azu_host
        connection_details['port'] = self.azu_port
        connection_details['secure'] = self.azu_secure
        if len(self.azu_user) > 0:
            connection_details['user'] = self.azu_user
            connection_details['password'] = self.azu_pass

        # make connection
        try:
            self.connection = make_connection(**connection_details)
            self.connection.is_persistent_connection = True
            self.interface = self.connection.get_plugin_interface()
        except Exception, e:
            self.logger.error("could not connect to Azureus-Server (%s)" % e)
            return False
Ejemplo n.º 4
0
    def initialize(self):

        # flu

        # check dirs
        if not self.checkDirs():
            printError("Error checking dirs. path: %s" % self.tf_path)
            return False

        # write pid-file
        self.pid = (str(os.getpid())).strip()
        printMessage("writing pid-file %s (%s)" % (self.flu_filePid, self.pid))
        try:
            pidFile = open(self.flu_filePid, 'w')
            pidFile.write(self.pid + "\n")
            pidFile.flush()
            pidFile.close()
        except:
            printError("Failed to write pid-file %s (%s)" %
                       (self.flu_filePid, self.pid))
            return False

        # delete command-file if exists
        if os.path.isfile(self.flu_fileCommand):
            try:
                printMessage("removing command-file %s ..." %
                             self.flu_fileCommand)
                os.remove(self.flu_fileCommand)
            except:
                printError("Failed to delete commandfile %s" %
                           self.flu_fileCommand)
                return False

        # load transfers
        self.loadTransfers()

        # azu
        printMessage("connecting to Azureus-Server (%s:%d)..." %
                     (self.azu_host, self.azu_port))

        # set connection details
        connection_details = {}
        connection_details['host'] = self.azu_host
        connection_details['port'] = self.azu_port
        connection_details['secure'] = self.azu_secure
        if len(self.azu_user) > 0:
            connection_details['user'] = self.azu_user
            connection_details['password'] = self.azu_pass

        # make connection
        try:
            self.connection = make_connection(**connection_details)
            self.connection.is_persistent_connection = True
            self.interface = self.connection.get_plugin_interface()
        except:
            printError("could not connect to Azureus-Server")
            printException()
            return False

        # azureus version
        self.azu_version_str = str(self.connection.get_azureus_version())
        self.azu_version_str = self.azu_version_str.replace(", ", ".")
        self.azu_version_str = self.azu_version_str.replace("(", "")
        self.azu_version_str = self.azu_version_str.replace(")", "")
        printMessage("connected. Azureus-Version: %s" % self.azu_version_str)

        # download-manager
        self.dm = self.interface.getDownloadManager()
        if self.dm is None:
            printError("Error getting Download-Manager object")
            return False

        # write stat-file and return
        return self.writeStatFile()
Ejemplo n.º 5
0
    def initialize(self):

        # flu

        # check dirs
        if not self.checkDirs():
            printError("Error checking dirs. path: %s" % self.tf_path)
            return False

        # write pid-file
        self.pid = (str(os.getpid())).strip()
        printMessage("writing pid-file %s (%s)" % (self.flu_filePid, self.pid))
        try:
            pidFile = open(self.flu_filePid, "w")
            pidFile.write(self.pid + "\n")
            pidFile.flush()
            pidFile.close()
        except:
            printError("Failed to write pid-file %s (%s)" % (self.flu_filePid, self.pid))
            return False

        # delete command-file if exists
        if os.path.isfile(self.flu_fileCommand):
            try:
                printMessage("removing command-file %s ..." % self.flu_fileCommand)
                os.remove(self.flu_fileCommand)
            except:
                printError("Failed to delete commandfile %s" % self.flu_fileCommand)
                return False

        # load transfers
        self.loadTransfers()

        # azu
        printMessage("connecting to Azureus-Server (%s:%d)..." % (self.azu_host, self.azu_port))

        # set connection details
        connection_details = {}
        connection_details["host"] = self.azu_host
        connection_details["port"] = self.azu_port
        connection_details["secure"] = self.azu_secure
        if len(self.azu_user) > 0:
            connection_details["user"] = self.azu_user
            connection_details["password"] = self.azu_pass

        # make connection
        try:
            self.connection = make_connection(**connection_details)
            self.connection.is_persistent_connection = True
            self.interface = self.connection.get_plugin_interface()
        except:
            printError("could not connect to Azureus-Server")
            printException()
            return False

        # azureus version
        self.azu_version_str = str(self.connection.get_azureus_version())
        self.azu_version_str = self.azu_version_str.replace(", ", ".")
        self.azu_version_str = self.azu_version_str.replace("(", "")
        self.azu_version_str = self.azu_version_str.replace(")", "")
        printMessage("connected. Azureus-Version: %s" % self.azu_version_str)

        # download-manager
        self.dm = self.interface.getDownloadManager()
        if self.dm is None:
            printError("Error getting Download-Manager object")
            return False

        # write stat-file and return
        return self.writeStatFile()