Пример #1
0
 def get_number_cat(cls):
     """ Class method that retrieves the number of categories
     """
     connection = db.connect()
     nb_cat = db.req_categories_count(connection)
     db.disconnect(connection)
     return nb_cat
Пример #2
0
 def remove(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute("delete from products where id = :input_id",
                    input_id=self.get_id())
     database.commit(db)
     database.disconnect(db)
Пример #3
0
    def get_default_address(self, type_string):
        # Returns default address of type type_string
        db = database.connect()
        cursor = database.get_cursor(db)

        cursor.execute("select id from address_types where address_type = :input_str", \
                        input_str = str(type_string))

        type_id = cursor.fetchone()
        if type_id:
            type_id = type_id[0]
        else:
            raise ValueError("Type string given (%s) not valid type" %
                             str(type_string))

        cursor.execute("select id from addresses \
                        where default_flag = 1 and address_type_id = :input_type \
                        and person_id = :input_pid"                                                   , \
                        input_type = type_id, input_pid = self.get_id())
        address_id = cursor.fetchone()

        database.disconnect(db)

        if address_id:
            address_reference = address.Address(address_id[0])
        else:
            address_reference = None

        return address_reference
Пример #4
0
    def modify_quantity(self, product, new_quantity):
        db = database.connect()
        cursor = database.get_cursor(db)
        if isinstance(new_quantity, int) and new_quantity >= 0:
            product_id = product.get_id()
            cursor.execute("select quantity from warehouse_to_product \
                            where product_id = :input_pid and warehouse_id = :input_wid"                                                                                        , \
                            input_pid = product_id, input_wid = self.get_id())
            current_quantity = cursor.fetchone()

            if current_quantity:
                # Ensuring product is in warehouse stock
                current_quantity = int(current_quantity[0])
                if current_quantity == new_quantity:
                    # Do nothing if quantity doesn't change
                    pass
                elif new_quantity == 0:
                    # Remove line in DB is new quantity is zero
                    cursor.execute("delete from warehouse_to_product \
                                    where product_id = :input_pid and warehouse_id = :input_wid"                                                                                                , \
                                    input_pid = product_id, input_wid = self.get_id())
                    database.commit(db)
                else:
                    # Otherwise just update the quantity
                    cursor.execute("update warehouse_to_product set quantity = :input_quantity \
                                    where product_id = :input_pid and warehouse_id = :input_wid"                                                                                                , \
                                    input_quantity = new_quantity, input_pid = product_id, \
                                    input_wid = self.get_id())
                    database.commit(db)
        else:
            raise ValueError("new quantity must be positive integer value")
        database.disconnect(db)
Пример #5
0
	def wrapper(*args, **kwargs):
		passthrough = False

		passthroughExtensions = (".html", ".xml", "txt")
		passthroughPaths = ("/resources", "/views", "/static", "/theme/static")

		test1 = [ext for ext in passthroughExtensions if ext in request.path]
		test2 = [p for p in passthroughPaths if request.path.startswith(p)]
		passthrough = (len(test1) > 0 or len(test2) > 0)

		#
		# Connect to our database
		#
		if len(config.ENVIRONMENT["DB_HOST"]):
			database.connect(
				engine   = "mysql",
				host     = config.ENVIRONMENT["DB_HOST"],
				port     = config.ENVIRONMENT["DB_PORT"],
				database = config.ENVIRONMENT["DB_NAME"],
				user     = config.ENVIRONMENT["DB_USER"],
				password = config.ENVIRONMENT["DB_PASSWORD"]
			)


		#
		# Get the current theme and add framework paths
		#
		if installservice.isEngineInstalled():
			request.themeName = themeservice.getThemeName()
			themeservice.addThemeToTemplatePath(themeName=request.themeName)

		if not passthrough:
			if not installservice.isEngineInstalled() and not request.path.startswith("/install"):
				redirect("/install")

			#
			# Setup session and environment stuff
			#
			request.session = request.environ.get("beaker.session")
			request.all = dict(list(request.query.items()) + list(request.forms.items()))

			if installservice.isEngineInstalled():
				request.timezone = engineservice.getBlogTimezone()
				config.TIMEZONE = request.timezone
			else:
				config.TIMEZONE = "UTC"

			#
			# Finally call the the next method in the chain
			#
			body = callback(*args, **kwargs)
			database.disconnect()

			return body

		else:
			body = callback(*args, **kwargs)
			database.disconnect()

			return body
Пример #6
0
    def remove_product(self, product):
        db = database.connect()
        cursor = database.get_cursor(db)
        product_id = product.get_id()
        cursor.execute("select quantity from warehouse_to_product \
                        where product_id = :input_pid and warehouse_id = :input_wid"                                                                                    , \
                        input_pid = product_id, input_wid = self.get_id())
        current_quantity = cursor.fetchone()

        if current_quantity:
            # The item is already in this table in the DB, just decriment quantity
            decrimented_quantity = int(current_quantity[0]) - 1
            if decrimented_quantity > 0:
                # Removing one will not remove all instances of that product
                cursor.execute("update warehouse_to_product set quantity = :input_quantity \
                                where product_id = :input_pid and warehouse_id = :input_wid"                                                                                            , \
                                input_quantity = decrimented_quantity, input_pid = product_id, \
                                input_wid = self.get_id())
                database.commit(db)
            else:
                # Remove the line from the DB if product has quantity of zero
                cursor.execute("delete from warehouse_to_product \
                                where product_id = :input_pid and warehouse_id = :input_wid"                                                                                            , \
                                input_pid = product_id, input_wid = self.get_id())
                database.commit(db)
        else:
            # The item is not yet in the warehouse's stock, so do nothing
            pass
        database.disconnect(db)
Пример #7
0
    def modify_expiration_date(self, new_expiration_month,
                               new_expiration_year):
        # Type- and value-checking inputs
        if not isinstance(new_expiration_month, int):
            raise ValueError("Expiration month must be integer value")
        if not isinstance(new_expiration_year, int):
            raise ValueError("Expiration year must be integer value")
        if new_expiration_month > 12 or new_expiration_month < 1:
            raise ValueError("Expiration month must be between 1 and 12")
        if not len(str(new_expiration_year)) == 4:
            raise ValueError("Expiration year must be 4 digit integer")

        # Formatting the date
        expiration_date = format_date(new_expiration_month,
                                      new_expiration_year)

        db = database.connect()
        cursor = database.get_cursor(db)

        cursor.execute("update credit_cards set expiration_date = :input_date \
                        where id = :input_id"                                             ,\
                        input_date = expiration_date, input_id = self.get_id())

        database.commit(db)
        database.disconnect(db)
Пример #8
0
    def new_warehouse(capacity,
                      street,
                      city,
                      state_string,
                      zip_code,
                      apartment_no=None):
        # Adding new warehouse to database, and returning reference to that warehouse
        db = database.connect()
        cursor = database.get_cursor(db)
        warehouse_address = address.Address.new_address(street, city, state_string, zip_code,\
            "warehouse", apt_no = apartment_no)
        address_id = warehouse_address.get_id()

        if isinstance(capacity, (int, float)):
            returned_id = cursor.var(database.cx_Oracle.NUMBER)
            capacity = int(capacity)
            cursor.execute("insert into warehouses \
                            (capacity, address_id) values (:input_capacity, :input_address) \
                            returning id into :new_warehouse_id"                                                                , \
                            input_capacity = capacity, input_address = address_id, \
                            new_warehouse_id = returned_id)
            database.commit(db)

        returned_id = int(returned_id.getvalue())

        database.disconnect(db)
        return Warehouse(returned_id)
Пример #9
0
    def modify_address(self, new_address_reference):
        # Ensuring address' ID is in addresses table AND it is a billing address
        db = database.connect()
        cursor = database.get_cursor(db)

        cursor.execute("select id from addresses \
                        where id = :input_id"                                             , \
                        input_id = new_address_reference.get_id())
        address_id = cursor.fetchone()

        if not address_id:
            raise ValueError("Address not found in addresses table")
        else:
            address_id = address_id[0]

        address_reference = address.Address(address_id)
        if not address_reference.get_type() == "billing":
            raise ValueError("Address must be billing type. Type is %s." %
                             address_reference.get_type())

        cursor.execute("update credit_cards set billing_addr_id = :input_addr \
                        where id = :input_id"                                             ,\
                        input_addr = address_id, input_id = self.get_id())

        database.commit(db)
        database.disconnect(db)
Пример #10
0
    def new_order(customer):
        db = database.connect()
        cursor = database.get_cursor(db)

        returned_id = cursor.var(database.cx_Oracle.NUMBER)

        cursor.execute("select id from order_statuses where order_status = :input_status", \
                        input_status = "pending")
        status_id = cursor.fetchone()[0]

        if isinstance(customer, person.Person):
            cursor.execute("insert into orders (person_id, status_id) \
                            values (:input_pid, :input_sid) \
                            returning id into :output_id"                                                         , \
                            input_pid = customer.get_id(), input_sid = status_id, \
                            output_id = returned_id)
            database.commit(db)

        else:
            raise ValueError("Requires valid person instance")

        returned_id = int(returned_id.getvalue())
        this_order = Order(returned_id)

        database.disconnect(db)

        ship_addr = customer.get_default_address("shipping")
        if ship_addr:
            this_order.modify_shipping_address(ship_addr)

        return this_order
Пример #11
0
    def set_default_flag(self, state):
        if state != True and state != False:
            raise ValueError("Requires True or False")

        if state == True:
            flag = 1
        elif state == False:
            flag = 0

        db = database.connect()
        cursor = database.get_cursor(db)

        # Get id of own type
        cursor.execute("select id from address_types where address_type = :input_type", \
                        input_type = self.get_type())
        type_id = cursor.fetchone()[0]

        if state == True and self.get_person():
            # If address has a person remove other true flags so only one remains of this type
            cursor.execute("update addresses set default_flag = 0 \
                            where person_id = :input_id and default_flag = 1 \
                            and address_type_id = :input_tid"                                                             , \
                            input_id = self.get_person().get_id(), input_tid = type_id)
            database.commit(db)

        cursor.execute("update addresses set default_flag = :input_flag \
                        where id = :input_id"                                             , \
                        input_flag = flag, input_id = self.get_id())

        database.commit(db)
        database.disconnect(db)
Пример #12
0
 def modify_name(self, new_name):
     db = database.connect()
     cursor = database.get_cursor(db)
     if new_name:
         cursor.execute("update products set name = :name_string where id = :product_id", name_string = new_name, \
             product_id = self.get_id())
     database.commit(db)
     database.disconnect(db)
Пример #13
0
 def get_name(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute("select name from products where id=:product_id",
                    product_id=self._id)
     name = cursor.fetchone()[0]
     database.disconnect(db)
     return name
Пример #14
0
 def __init__(self, index):
     """ Class initializer
     """
     connection = db.connect()
     self.entries_list = db.req_categories_for_page_entries(connection, \
                                                            index*self.OFFSET, \
                                                            self.OFFSET)
     db.disconnect(connection)
Пример #15
0
 def get_capacity(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute("select capacity from warehouses where id = :warehouse_id", \
                     warehouse_id = self.get_id())
     cap = cursor.fetchone()[0]
     database.disconnect(db)
     return cap
Пример #16
0
def registerPlayer(name):
    """Adds a player to the tournament database.
    Args:
      name: the player's full name (need not be unique).
    """
    db, c = database.connect()
    c.execute('INSERT INTO players VALUES(default, %s)', (name, ))
    database.disconnect(db, True)
Пример #17
0
def deleteMatches():
    """Remove all the match records from the database.
    Args: None
    """
    db, c = database.connect()
    query = 'DELETE FROM matches'
    c.execute(query)
    database.disconnect(db, commit=True)
Пример #18
0
def deletePlayers():
    """Remove all the player records from the database.
    Args: None
    """
    db, c = database.connect()
    query = 'delete from players'
    c.execute(query)
    database.disconnect(db, commit=True)
Пример #19
0
 def modify_size(self, new_size):
     # ensuring it's a number:
     db = database.connect()
     cursor = database.get_cursor(db)
     if isinstance(new_size, (int, float, long)):
         cursor.execute("update products set product_size = :psize where id = :product_id", \
             psize = new_size, product_id = self.get_id())
         database.commit(db)
     database.disconnect(db)
Пример #20
0
 def get_alcohol_content(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute(
         "select alcohol_content from products where id = :product_id",
         product_id=self._id)
     alcohol_content = cursor.fetchone()[0]
     database.disconnect(db)
     return alcohol_content
Пример #21
0
 def get_description(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute(
         "select description from products where id = :product_id",
         product_id=self._id)
     description = cursor.fetchone()[0]
     database.disconnect(db)
     return description
Пример #22
0
 def get_nutrition_facts(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     cursor.execute(
         "select nutrition_facts from products where id = :product_id",
         product_id=self._id)
     nutrition_facts = cursor.fetchone()[0]
     database.disconnect(db)
     return nutrition_facts
Пример #23
0
    def new_person(username, password, first_name, last_name, type_string, middle_initial = None, \
        salary = None, job_title = None):
        db = database.connect()
        cursor = database.get_cursor(db)
        returned_id = cursor.var(database.cx_Oracle.NUMBER)

        # getting person type ID from type_string
        cursor.execute("select id from person_types where person_type = :input_type", \
                        input_type = type_string)
        type_id = cursor.fetchone()
        if type_id:
            type_id = type_id[0]
        else:
            raise ValueError("Type given (%s) not valid person type" %
                             str(type_string))

        hashed_password = hash_password(username, password)

        if middle_initial:
            # Trimming middle initial
            middle_initial = middle_initial[0]

            cursor.execute("insert into persons \
                            (username, password, first_name, middle_initial, last_name, \
                            person_type_id, balance) \
                            values (:input_username, :input_password, \
                            :input_first, :input_middle, :input_last, :input_type_id, 0) \
                            returning id into :output_id"                                                         , \
                            input_username = username, input_password = hashed_password, \
                            input_first = first_name, input_middle = middle_initial, \
                            input_last = last_name, input_type_id = type_id, \
                            output_id = returned_id)
            database.commit(db)
        else:
            cursor.execute("insert into persons \
                            (username, password, first_name, last_name, \
                            person_type_id, balance) \
                            values (:input_username, :input_password, \
                            :input_first, :input_last, :input_type_id, 0) \
                            returning id into :output_id"                                                         , \
                            input_username = username, input_password = hashed_password, \
                            input_first = first_name, \
                            input_last = last_name, input_type_id = type_id, \
                            output_id = returned_id)
            database.commit(db)

        database.disconnect(db)

        returned_id = returned_id.getvalue()
        reference = Person(returned_id)

        if salary:
            reference.modify_salary(salary)
        if job_title:
            reference.modify_job_title(job_title)

        return reference
Пример #24
0
 def initiates_saves_index(cls):
     """Class method that creates the index of pages
     """
     connection = db.connect()
     nb_saves = db.req_saves_count(connection)
     nb_pages_saves = int(ceil(nb_saves / cls.OFFSET))
     for page_number in range(nb_pages_saves):
         page_save = PageSaves(page_number)
         cls.SAVES_PAGES_INDEX.append(page_save)
     db.disconnect(connection)
Пример #25
0
 def get_remaining_capacity(self):
     db = database.connect()
     cursor = database.get_cursor(db)
     total_used_space = 0
     for product in self.get_stock():
         total_used_space += product.get_size() * self.get_product_quantity(
             product)
     remaining_cap = self.get_capacity() - total_used_space
     database.disconnect(db)
     return remaining_cap
Пример #26
0
 def InsertNewSpares(self):
     print "SpareDB.InsertNewSpares start"
     db = database.connect()
     new_spares = self.getNewSpares()
     for spare in new_spares:
         self.logfile.write("inserting spare " + str(spare) +
                            " into confdb")
         spare.insert(db)
     database.disconnect(db)
     print "SpareDB.InsertNewSpares end"
Пример #27
0
    def modify_balance(self, addition):
        db = database.connect()
        cursor = database.get_cursor(db)
        new_balance = self.get_balance() + addition

        cursor.execute("update persons set balance = :input_balance where id = :input_id", \
                        input_balance = new_balance, input_id = self.get_id())

        database.commit(db)
        database.disconnect(db)
Пример #28
0
def get_all_warehouses():
    # Returns list of references to warehouses
    db = database.connect()
    cursor = database.get_cursor(db)
    warehouses = []
    cursor.execute("select id from warehouses")
    ids = cursor.fetchall()
    for id_tuple in ids:
        warehouses.append(Warehouse(id_tuple[0]))
    database.disconnect(db)
    return warehouses
Пример #29
0
 def __init__(self, name_category_fr, ps_name, ps_brand, ps_quantity):
     """ Class initializer
     """
     connection = db.connect()
     self.entries_list = db.req_recommandations(connection, \
                                                name_category_fr, \
                                                ps_name, \
                                                ps_brand, \
                                                ps_quantity, \
                                                self.OFFSET)
     db.disconnect(connection)
Пример #30
0
    def modify_job_title(self, new_title):
        db = database.connect()
        cursor = database.get_cursor(db)

        cursor.execute("update persons \
                        set job_title = :input_title \
                        where id = :input_id"                                             ,  \
                        input_title = str(new_title), input_id = self.get_id())

        database.commit(db)
        database.disconnect(db)
Пример #31
0
    def get_username(self):
        db = database.connect()
        cursor = database.get_cursor(db)

        cursor.execute("select username from persons where id = :input_id", \
                        input_id = self.get_id())
        user = cursor.fetchone()[0]

        database.disconnect(db)

        return user
Пример #32
0
def install():
	if "btnSubmit" in request.all:
		installservice.setupConfigFile(
			dbServer      = request.all["databaseServer"],
			dbName        = request.all["databaseName"],
			dbUser        = request.all["databaseUserName"],
			dbPass        = request.all["databasePassword"],
			blogTitle     = request.all["blogTitle"],
			postsPerPage  = request.all["postsPerPage"],
			hashKey1      = request.all["hashKey1"],
			hashKey2      = request.all["hashKey2"],
			encryptionKey = request.all["encryptionKey"],
			encryptionIV  = request.all["encryptionIV"]
		)

		installservice.setupDatabase(
			dbServer  = request.all["databaseServer"],
			dbPort    = 3306,
			dbName    = request.all["databaseName"],
			dbUser    = request.all["databaseUserName"],
			dbPass    = request.all["databasePassword"],
			email     = request.all["adminEmail"],
			password  = request.all["adminPassword"],
			firstName = request.all["adminFirstName"],
			lastName  = request.all["adminLastName"],
			timezone  = request.all["timezone"],
			hashKey1  = request.all["hashKey1"],
			hashKey2  = request.all["hashKey2"],
		)

		database.disconnect()
		imp.reload(config)

		database.connect(
			engine   = "mysql",
			host     = config.ENVIRONMENT["DB_HOST"],
			port     = config.ENVIRONMENT["DB_PORT"],
			database = config.ENVIRONMENT["DB_NAME"],
			user     = config.ENVIRONMENT["DB_USER"],
			password = config.ENVIRONMENT["DB_PASSWORD"]
		)

		redirect("/installcomplete")

	return {
		"timezones": dthelper.getTimezoneArray()
	}
Пример #33
0
    def lookup_uuts(self, rpt):
        """lookup_uuts(), returns a list of UUTs
        """
        # cf is a RootContainer object
        cf = self._config
        # read slstorage element (the chasis) to get the number of slots there.
        #slots = cf.testbed._get_chassisItems().get_slots()

        ui = self._config.userinterface
        
        uut_dict = self.get_uuts_from_cmd_line()
        """
        use the len of the dictionary to determine if UUTs are specified
        in the command line.
        """
        # lists to store each uut information 
        sn_list = []
        newUUT_list = []
        #cfuut_list = []
        conf_dict = {}

        #plims = [d.name for (i,d) in slots]
        if len(uut_dict) > 0:
           sn_list = uut_dict.values()  # extract plim values as specified
        else:  # nothing is specified, prompt user
            pass
            #if self._config.plim is None:
            #    plim = ui.choose(plims, len(plims)-1, prompt="Plimulator holding UUT? ")
            #else:
            #    plim = self._config.plim
            #sn_list.append(plim)

        #print "Verifying UUT serial number against database."
        for sn in sn_list:
            serno = sn
            self._config.serno = serno

            try:
                dbuut = list(database.UUTBuild.select(database.UUTBuild.q.UutSN==serno))[0]

            except:
                # XXX: need to take care of DB handling
                sys_DBURI = cf.DBURI + "-1"
                print "serial number not found in local database -- try %s" % sys_DBURI
                database.disconnect()
                try:
                    database.connect2db(sys_DBURI)
                    dbuut = list(database.UUTBuild.select(database.UUTBuild.q.UutSN==serno))[0]
                except:
                    ex, val, tb = sys.exc_info()
                    ui.error("The serial number was not found in the database!")
                    rpt.add_message("ERROR", "No matching serial number found.")
                    raise TestSuiteAbort, "Suite aborted. UUT %s not found." %(serno)

                #ex, val, tb = sys.exc_info()
                #ui.error("The serial number \"%s\" returned from the UUT was not found in the database!" \
                #%(serno))
                #rpt.add_message("ERROR", "No matching serial number found.")
                #raise TestSuiteAbort, "Suite aborted. UUT %s not found." %(serno)

            ui.info("serial number was found")
            database.disconnect()
            database.connect2db(cf.DBURI)   #reconnect back to local DB

            slot_name = self.get_key_by_value(uut_dict, serno)
            # dictionary value is now a dictionary too
            # the keys are 'uut_obj' 'plim_name' 'plim_ip' 'slot' and 'uut_id'
            conf_dict[serno] = {}
            
            # if the testbed has uses a XoomServer use the port and address
            tb = self._config.testbed
            ## value of the dictionary is a list 
            conf_dict[serno]['slot'] = slot_name.split('slot')[1] # slot on which the card sits
            
            if cf.upgrade:
                uut_slot_name = "UUT_slot%s_mfgtest" % conf_dict[serno]['slot']
            else:
                uut_slot_name = "UUT_slot%s" % (conf_dict[serno]['slot'])
                try:
                    uut_slot_mike_name = "UUT_slot%s_mike" % (conf_dict[serno]['slot'])
                    conf_dict[serno]['mike'] = tb[uut_slot_mike_name]
                    #conf_dict[serno]['mike'].close()
                except:
                    ui.diagnostic("Warning, Mike-shell is not found!")
                
                try:
                    uut_slot_mike_debug_name = "%s_mike_debug" % (uut_slot_name)
                    conf_dict[serno]['mike_debug'] = tb[uut_slot_mike_debug_name]
                except:
                    ui.error("No mike_debug port defined in database!")
            
            conf_dict[serno]['obj']  = tb[uut_slot_name]
            conf_dict[serno]['id']   = dbuut.id    # via SQL DB lookup
            cf.uut_id = dbuut.id
        	self._config.uut_id = dbuut.id
            pn = cf.part_no
            if ((not cf.part_no.startswith('2'))):
                if not cf._IGNORE_SN_CHECK:
                    ui.info("Verifying serial number on the board against command line")
                    sn_from_card = conf_dict[serno]['obj'].SN

                    if sn_from_card != serno:
                        raise TestSuiteAbort, "Serial number provided '%s' does not match EEPROM entry '%s'" % (serno, sn_from_card)
                    else:
                        ui.info("Serial number provided '%s' matches EEPROM entry '%s'" % (serno, sn_from_card))
                else:
                    ui.info("Serial number check skipped...")
            else:
                ui.info("Serial number check skipped...")
Пример #34
0
    def get_uut(self, rpt):
        """get_uut()
        """
        cf = self._config
        ui = self._config.userinterface
        if not cf.has_key('ser_no') and not cf.slot_specified:
            serno = ui.user_input("Enter serial number of UUT: ")
        else:
            serno = cf.ser_no
        
        try:
            dbuut = list(database.UUTBuild.select(database.UUTBuild.q.UutSN==serno))[0]
        except:
            sys_DBURI = cf.DBURI + "-1"
            print "serial number not found in local database -- try %s" % sys_DBURI
            database.disconnect()
            try:
                database.connect2db(sys_DBURI)
                dbuut = list(database.UUTBuild.select(database.UUTBuild.q.UutSN==serno))[0]
            except:
                ex, val, tb = sys.exc_info()
                ui.error("The serial number was not found in the database!")
                rpt.add_message("ERROR", "No matching serial number found.")
                raise TestSuiteAbort, "Suite aborted. UUT %s not found." %(serno)

            ui.info("serial number was found")
            database.disconnect()
            database.connect2db(cf.DBURI)   #reconnect back to local DB

        try:
            cfuut = cf.testbed['UUT'] # get 860 config
            self._config.testbed.uut_sw_version = cfuut.version()
        except:
            cfuut = cf.testbed.UUT
            self._config.testbed.uut_sw_version = None
        
        if not cf._IGNORE_SN_CHECK:
            if self._config.testbed.uut_sw_version is None:
                raise TestSuiteAbort, "UUT has not finished booting up yet, please wait for a minute and try again..."
                
        cfuut.serialNumber = dbuut.UutSN
        cfuut.modelNumber = dbuut.UutAssyNum
        cfuut.revision = dbuut.UutAssyRev
        cfuut.date = dbuut.Date
        cfuut.uut_id = dbuut.id
        self._config.testbed.support_sw_version = self._config.module_ID
        from copy import copy
        self._config.testbed.UUT_INFO = copy(cfuut)
        if ((not cf.part_no.startswith('2'))):
            if (not cf._IGNORE_SN_CHECK):
                sn_from_card = cfuut.get_sn()

                if sn_from_card != cfuut.serialNumber:
                    raise TestSuiteAbort, "Serial number given '%s' does not match that of the card '%s'" % (cfuut.serialNumber, sn_from_card)
                else:
                    ui.info("Serial number given '%s' matches that of the card '%s'" % (dbuut.UutSN, sn_from_card))
            else:
                ui.info("Serial number check skipped...")
        else:
            ui.info("Serial number check skipped...")

        self._config.uut_id = cfuut.uut_id
        self._config.cfuut = cfuut
        return cfuut
Пример #35
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import database
import sources
import analyzer

database.connect()

# get the search terms that will be crawled
# expected result: ((term1, 1), (term2, 2), (term3, 3))
searchTerms = database.getSearchTerms()

# fetch data for all terms from all sources, 
# analyze the data and store the results in DB
for sourceHandler in sources.queryHandlers:
    for term in searchTerms:

        # get raw search data from this source
        data = sourceHandler( term['name'] )

        # parse raw data into semantic information
        analyzer.parse( data )

        # store in the database
        database.saveData( data, term['id'] )

database.disconnect()