Example #1
0
    def run(self):
        """
        This function runs the class in a loop unless the
        one_pass or one_pass_WU_N flags are set. Before execution
        parse_args() is called, the xml config file is loaded and
        the SIGINT signal is hooked to the sigint_handler method.
        """
        self.parse_args(sys.argv[1:])
        self.config = configxml.default_config().config

        # retrieve app where name = app.name
        database.connect()
        app=database.Apps.find1(name=self.appname)
        database.close()

        signal.signal(signal.SIGINT, self.sigint_handler)

        # do one pass or execute main loop
        if self.one_pass:
            self.do_pass(app)
        else:
            # main loop
            while(1):
                database.connect()
                workdone = self.do_pass(app)
                database.close()
                if not workdone:
                    time.sleep(self.sleep_interval)
Example #2
0
    def run(self):
        """
        This function runs the class in a loop unless the
        one_pass or one_pass_WU_N flags are set. Before execution
        parse_args() is called, the xml config file is loaded and
        the SIGINT signal is hooked to the sigint_handler method.
        """
        self.parse_args(sys.argv[1:])
        self.config = configxml.default_config().config

        # retrieve app where name = app.name
        database.connect()
        app = database.Apps.find1(name=self.appname)
        database.close()

        signal.signal(signal.SIGINT, self.sigint_handler)

        # do one pass or execute main loop
        if self.one_pass:
            self.do_pass(app)
        else:
            # main loop
            while 1:
                database.connect()
                workdone = self.do_pass(app)
                database.close()
                if not workdone:
                    time.sleep(self.sleep_interval)
Example #3
0
def connect(config = None, nodb = False):
    """Connect if not already connected, using config values."""
    if get_dbconnection():
        return 0
    config = config or configxml.default_config().config
    if nodb:
        db = ''
    else:
        db = config.db_name
    
    host=config.__dict__.get('db_host','')
    port=""
    if ':' in host:
        host,port=config.__dict__.get('db_host','').split(":")

    if port == '':
        port = 3306
    else:
        port = int(port)
    do_connect(db=db,
               host=host,
               port=port,
               user=config.__dict__.get('db_user',''),
               passwd=config.__dict__.get('db_passwd', ''))
    return 1
Example #4
0
def get_output_file_path(filename):
    """ Return the filename's path in the upload directory
        Use this if you're developing a validator/assimilator in Python
    """
    config = configxml.default_config()
    fanout = long(config.config.uldl_dir_fanout)
    try:
        s = md5(filename).hexdigest()[1:8]
    except TypeError:
        s = md5.new(filename).hexdigest()[1:8]
    x = long(s, 16)
    return "%s/%x/%s" % (config.config.upload_dir, x % fanout, filename)
Example #5
0
 def __init__(self):
     DCAPI_Backend.__init__(self)
     try:
         self.config = configxml.default_config()
     except:
         raise SystemExit("Failed to locate/parse the BOINC project configuration")
     self.master_keys.extend([("ProjectRootDir", False)])
     self.client_keys.extend([("Redundancy", False),
                              ("MaxOutputSize", False),
                              ("MaxMemUsage", False),
                              ("MaxDiskUsage", False),
                              ("EstimatedFPOps", True),
                              ("MaxFPOps", True),
                              ("DelayBound", True)])
Example #6
0
 def __init__(self):
     DCAPI_Backend.__init__(self)
     try:
         self.config = configxml.default_config()
     except:
         raise SystemExit(
             "Failed to locate/parse the BOINC project configuration")
     self.master_keys.extend([("ProjectRootDir", False)])
     self.client_keys.extend([("Redundancy", False),
                              ("MaxOutputSize", False),
                              ("MaxMemUsage", False),
                              ("MaxDiskUsage", False),
                              ("EstimatedFPOps", True), ("MaxFPOps", True),
                              ("DelayBound", True)])
Example #7
0
    def run(self):
        self.parse_args(sys.argv[1:])
        self.config = configxml.default_config().config

        # retrieve app where name = app.name
        database.connect()
        database.Apps.find1(name=self.appname)

        conn = db_base.get_dbconnection()

        user_count = 0
        credit_count = 0

        transaction = self._connection.begin()

        query_cursor = conn.cursor()
        delete_cursor = conn.cursor()
        query_cursor.execute('select userid, workunitid from credited_job ')
        results = query_cursor.fetchall()
        for result in results:
            user_count += 1
            user_id = result['userid']
            area_id = result['workunitid']
            area_user = self._connection.execute(
                select([AREA_USER]).where(
                    and_(AREA_USER.c.userid == user_id,
                         AREA_USER.c.area_id == area_id))).first()
            if area_user is None:
                area = self._connection.execute(
                    select([AREA]).where(AREA.c.area_id == area_id)).first()
                galaxy_id = area['galaxy_id']
                if area is None:
                    print 'Area', area_id, 'not found, User', user_id, 'not Credited'
                else:
                    AREA_USER.insert().values(userid=user_id, area_id=area_id)
                    GALAXY_USER.insert().prefix_with('IGNORE').values(
                        userid=user_id, galaxy_id=galaxy_id)
                    print 'User', user_id, 'Credited for Area', area_id
                    credit_count += 1

            delete_cursor.execute("delete from credited_job where userid = " +
                                  str(user_id) + "  and workunitid = " +
                                  str(area_id))

        transaction.commit()
        conn.commit()
        database.close()
        self._connection.close()
        print user_count, 'Users', credit_count, 'Credited'
Example #8
0
def create_database(srcdir, config = None, drop_first = False):
    ''' creates a new database. '''
    import boinc_path_config
    config = config or configxml.default_config().config
    connect(config, nodb=True)
    dbcon = get_dbconnection()
    cursor = dbcon.cursor()
    if drop_first:
        cursor.execute("drop database if exists %s"%config.db_name)
    cursor.execute("create database %s"%config.db_name)
    cursor.execute("use %s"%config.db_name)
    for file in ['schema.sql', 'constraints.sql', 'content.sql']:
        _execute_sql_script(cursor, os.path.join(srcdir, 'db', file))
    dbcon.commit()
    cursor.close()
def connect(config = None, nodb = False):
    """Connect if not already connected, using config values."""
    if get_dbconnection():
        return 0
    config = config or configxml.default_config().config
    if nodb:
        db = ''
    else:
        db = config.db_name
    
    host=config.__dict__.get('db_host','')
    do_connect(db=db,
               host=host,
               user=config.__dict__.get('db_user',''),
               passwd=config.__dict__.get('db_passwd', ''))
    return 1
Example #10
0
    def run(self):
        self.parse_args(sys.argv[1:])
        self.config = configxml.default_config().config

        # retrieve app where name = app.name
        database.connect()
        database.Apps.find1(name=self.appname)

        conn = db_base.get_dbconnection()

        user_count = 0
        credit_count = 0

        transaction = self._connection.begin()

        query_cursor = conn.cursor()
        delete_cursor = conn.cursor()
        query_cursor.execute('select userid, workunitid from credited_job ')
        results = query_cursor.fetchall()
        for result in results:
            user_count += 1
            user_id = result['userid']
            area_id = result['workunitid']
            area_user = self._connection.execute(select([AREA_USER]).where(and_(AREA_USER.c.userid == user_id, AREA_USER.c.area_id == area_id))).first()
            if area_user is None:
                area = self._connection.execute(select([AREA]).where(AREA.c.area_id == area_id)).first()
                galaxy_id = area['galaxy_id']
                if area is None:
                    print 'Area', area_id, 'not found, User', user_id, 'not Credited'
                else:
                    AREA_USER.insert().values(userid=user_id, area_id=area_id)
                    GALAXY_USER.insert().prefix_with('IGNORE').values(userid=user_id, galaxy_id=galaxy_id)
                    print 'User', user_id, 'Credited for Area', area_id
                    credit_count += 1

            delete_cursor.execute("delete from credited_job where userid = " + str(user_id) + "  and workunitid = " + str(area_id))

        transaction.commit()
        conn.commit()
        database.close()
        self._connection.close()
        print user_count, 'Users', credit_count, 'Credited'
Example #11
0
    def run(self):
        """
        This function runs the class in a loop unless the
        one_pass or one_pass_WU_N flags are set. Before execution
        parse_args() is called, the xml config file is loaded and
        the SIGINT signal is hooked to the sigint_handler method.
        """
        self.parse_args(sys.argv[1:])
        self.config = configxml.default_config().config

        try:
            with open("/home/boinc/findah/bin/sql_config.conf", 'r') as sql_config:
                buff = []
                i = 0
                for line in sql_config:
                    if line[0] != "#":
                         buff.append(line[:-1])
                         i += 1
        except Exception, e:
            self.logCritical("Error: %s", e)
            exit(1)