Example #1
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by component id or component name and product """

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch component data from it
        if inject:
            self._fetch(inject)
        # Initialized by product and component name
        elif name is not None and product is not None:
            # Detect product format
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            self._name = name
            # Index by name-product (only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just check that the id was provided
        elif id is None:
            raise NitrateError("Need either component id or both product "
                    "and component name to initialize the Component object.")
Example #2
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by component id or component name and product """

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch component data from it
        if inject:
            self._fetch(inject)
        # Initialized by product and component name
        elif name is not None and product is not None:
            # Detect product format
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            self._name = name
            # Index by name-product (only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just check that the id was provided
        elif id is None:
            raise NitrateError("Need either component id or both product "
                    "and component name to initialize the Component object.")
Example #3
0
    def __init__(self, id=None, login=None, email=None):
        """
        Initialize by user id, login or email

        Defaults to the current user if no id, login or email provided.
        If xmlrpc initial object dict provided as the first argument,
        data are initialized directly from it.
        """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(
                id or login or email)
        if initialized: return
        Nitrate.__init__(self, id, prefix="UID")

        # If inject given, fetch data from it
        if inject:
            self._fetch(inject)
        # Otherwise initialize by login or email
        elif name is not None:
            if "@" in name:
                self._email = name
            else:
                self._login = name
            self._index(name)
Example #4
0
    def _fetch(self, inject=None):
        """ Get the missing test plan type data """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing PlanType ID#{0} inject".format(inject["id"]))
        # Search by test plan type id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching test plan type " + self.identifier)
                inject = self._server.TestPlan.get_plan_type(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find test plan type for " + self.identifier)
        # Search by test plan type name
        else:
            try:
                log.info(u"Fetching test plan type '{0}'".format(self.name))
                inject = self._server.TestPlan.check_plan_type(self.name)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("PlanType '{0}' not found".format(
                        self.name))
        # Initialize data from the inject and index into cache
        log.debug("Initializing PlanType ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["name"]
        self._index(self.name)
Example #5
0
    def __init__(self, id=None, login=None, email=None):
        """
        Initialize by user id, login or email

        Defaults to the current user if no id, login or email provided.
        If xmlrpc initial object dict provided as the first argument,
        data are initialized directly from it.
        """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(
                id or login or email)
        if initialized: return
        Nitrate.__init__(self, id, prefix="UID")

        # If inject given, fetch data from it
        if inject:
            self._fetch(inject)
        # Otherwise initialize by login or email
        elif name is not None:
            if "@" in name:
                self._email = name
            else:
                self._login = name
            self._index(name)
Example #6
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by build id or product and build name """

        # Backward compatibility for 'build' argument (now called 'name')
        name = name if name is not None else kwargs.get("build")

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch build data from it
        if inject:
            self._fetch(inject)
        # Initialized by build name and product
        elif name is not None and product is not None:
            self._name = name
            # Detect product format
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            # Index by name-product (only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just check that the id was provided
        elif not id:
            raise NitrateError("Need either build id or both build name "
                    "and product to initialize the Build object.")
Example #7
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by version id or product and version """

        # Backward compatibility for 'version' argument (now called 'name')
        name = name if name is not None else kwargs.get("version")

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch tag data from it
        if inject:
            self._fetch(inject)
        # Initialize by version name and product
        elif name is not None and product is not None:
            self._name = name
            # Convert product into object if necessary
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            # Index by name/product (but only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just make sure the version id was provided
        elif not id:
            raise NitrateError("Need either version id or both product "
                    "and version name to initialize the Version object.")
Example #8
0
    def __init__(self, id=None, name=None):
        """
        Initialize the Product by id or name

        Examples:

        Product(60)
        Product(id=60)
        Product("Red Hat Enterprise Linux 6")
        Product(name="Red Hat Enterprise Linux 6")
        """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch test case data from it
        if inject:
            self._fetch(inject)
        # Initialize by name
        elif name is not None:
            self._name = name
            self._index(name)
        # Otherwise just check that the product id was provided
        elif not id:
            raise NitrateError("Need id or name to initialize Product")
Example #9
0
    def _fetch(self, inject=None):
        """ Get the missing test plan type data """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing PlanType ID#{0} inject".format(inject["id"]))
        # Search by test plan type id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching test plan type " + self.identifier)
                inject = self._server.TestPlan.get_plan_type(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find test plan type for " + self.identifier)
        # Search by test plan type name
        else:
            try:
                log.info(u"Fetching test plan type '{0}'".format(self.name))
                inject = self._server.TestPlan.check_plan_type(self.name)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("PlanType '{0}' not found".format(
                        self.name))
        # Initialize data from the inject and index into cache
        log.debug("Initializing PlanType ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["name"]
        self._index(self.name)
Example #10
0
    def __init__(self, id=None, name=None):
        """
        Initialize the Product by id or name

        Examples:

        Product(60)
        Product(id=60)
        Product("Red Hat Enterprise Linux 6")
        Product(name="Red Hat Enterprise Linux 6")
        """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch test case data from it
        if inject:
            self._fetch(inject)
        # Initialize by name
        elif name is not None:
            self._name = name
            self._index(name)
        # Otherwise just check that the product id was provided
        elif not id:
            raise NitrateError("Need id or name to initialize Product")
Example #11
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by version id or product and version """

        # Backward compatibility for 'version' argument (now called 'name')
        name = name if name is not None else kwargs.get("version")

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch tag data from it
        if inject:
            self._fetch(inject)
        # Initialize by version name and product
        elif name is not None and product is not None:
            self._name = name
            # Convert product into object if necessary
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            # Index by name/product (but only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just make sure the version id was provided
        elif not id:
            raise NitrateError("Need either version id or both product "
                    "and version name to initialize the Version object.")
Example #12
0
    def __init__(self, id=None, name=None, product=None, **kwargs):
        """ Initialize by build id or product and build name """

        # Backward compatibility for 'build' argument (now called 'name')
        name = name if name is not None else kwargs.get("build")

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch build data from it
        if inject:
            self._fetch(inject)
        # Initialized by build name and product
        elif name is not None and product is not None:
            self._name = name
            # Detect product format
            if isinstance(product, Product):
                self._product = product
            else:
                self._product = Product(product)
            # Index by name-product (only when the product name is known)
            if self.product._name is not NitrateNone:
                self._index("{0}---in---{1}".format(
                        self.name, self.product.name))
        # Otherwise just check that the id was provided
        elif not id:
            raise NitrateError("Need either build id or both build name "
                    "and product to initialize the Build object.")
Example #13
0
 def __new__(cls, id=None, *args, **kwargs):
     """ Create a new object, handle caching if enabled """
     # Convert login or email into name for better logging
     if "login" in kwargs or "email" in kwargs:
         name = kwargs.get("login", kwargs.get("email"))
         return Nitrate.__new__(cls, id=id, name=name, *args, **kwargs)
     else:
         return Nitrate.__new__(cls, id=id, *args, **kwargs)
Example #14
0
 def __new__(cls, id=None, *args, **kwargs):
     """ Create a new object, handle caching if enabled """
     # Convert login or email into name for better logging
     if "login" in kwargs or "email" in kwargs:
         name = kwargs.get("login", kwargs.get("email"))
         return Nitrate.__new__(cls, id=id, name=name, *args, **kwargs)
     else:
         return Nitrate.__new__(cls, id=id, *args, **kwargs)
Example #15
0
    def _fetch(self, inject=None):
        """ Fetch user data from the server """
        Nitrate._fetch(self, inject)

        if inject is None:
            # Search by id
            if self._id is not NitrateNone:
                try:
                    log.info("Fetching user " + self.identifier)
                    inject = self._server.User.filter({"id": self.id})[0]
                except IndexError:
                    raise NitrateError(
                            "Cannot find user for " + self.identifier)
            # Search by login
            elif self._login is not NitrateNone:
                try:
                    log.info(
                            "Fetching user for login '{0}'".format(self.login))
                    inject = self._server.User.filter(
                            {"username": self.login})[0]
                except IndexError:
                    raise NitrateError("No user found for login '{0}'".format(
                            self.login))
            # Search by email
            elif self._email is not NitrateNone:
                try:
                    log.info("Fetching user for email '{0}'".format(
                            self.email))
                    inject = self._server.User.filter({"email": self.email})[0]
                except IndexError:
                    raise NitrateError("No user found for email '{0}'".format(
                            self.email))
            # Otherwise initialize to the current user
            else:
                log.info("Fetching the current user")
                inject = self._server.User.get_me()
                self._index("i-am-current-user")

        # Initialize data from the inject and index into cache
        log.debug("Initializing user UID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._login = inject["username"]
        self._email = inject["email"]
        if inject["first_name"] and inject["last_name"]:
            self._name = inject["first_name"] + " " + inject["last_name"]
        else:
            self._name = None
        self._index(self.login, self.email)
Example #16
0
    def _fetch(self, inject=None):
        """ Fetch user data from the server """
        Nitrate._fetch(self, inject)

        if inject is None:
            # Search by id
            if self._id is not NitrateNone:
                try:
                    log.info("Fetching user " + self.identifier)
                    inject = self._server.User.filter({"id": self.id})[0]
                except IndexError:
                    raise NitrateError(
                            "Cannot find user for " + self.identifier)
            # Search by login
            elif self._login is not NitrateNone:
                try:
                    log.info(
                            "Fetching user for login '{0}'".format(self.login))
                    inject = self._server.User.filter(
                            {"username": self.login})[0]
                except IndexError:
                    raise NitrateError("No user found for login '{0}'".format(
                            self.login))
            # Search by email
            elif self._email is not NitrateNone:
                try:
                    log.info("Fetching user for email '{0}'".format(
                            self.email))
                    inject = self._server.User.filter({"email": self.email})[0]
                except IndexError:
                    raise NitrateError("No user found for email '{0}'".format(
                            self.email))
            # Otherwise initialize to the current user
            else:
                log.info("Fetching the current user")
                inject = self._server.User.get_me()
                self._index("i-am-current-user")

        # Initialize data from the inject and index into cache
        log.debug("Initializing user UID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._login = inject["username"]
        self._email = inject["email"]
        if inject["first_name"] and inject["last_name"]:
            self._name = inject["first_name"] + " " + inject["last_name"]
        else:
            self._name = None
        self._index(self.login, self.email)
Example #17
0
 def _fetch(self, inset=None):
     """ Save cache timestamp and initialize from inset if given """
     Nitrate._fetch(self)
     # Create copies of the initial set (if given)
     if inset is not None:
         log.debug("Initializing {0} for {1} from the inset".format(self.__class__.__name__, self._identifier))
         log.debug(pretty(inset))
         self._current = set(inset)
         self._original = set(inset)
     # Cache into container class
     if config.get_cache_level() >= config.CACHE_OBJECTS:
         self.__class__._cache[self._id] = self
     # Return True if the data are already initialized
     return inset is not None
Example #18
0
 def _fetch(self, inject=None):
     """ Fetch bug info from the server """
     Nitrate._fetch(self, inject)
     # No direct xmlrpc function for fetching so far
     if inject is None:
         raise NotImplementedError("Direct bug fetching not implemented")
     # Process provided inject
     self._id = int(inject["id"])
     self._bug = int(inject["bug_id"])
     self._system = int(inject["bug_system_id"])
     self._testcase = TestCase(int(inject["case_id"]))
     if inject["case_run_id"] is not None:
         self._caserun = CaseRun(int(inject["case_run_id"]))
     # Index the fetched object into cache
     self._index()
Example #19
0
 def _fetch(self, inject=None):
     """ Fetch bug info from the server """
     Nitrate._fetch(self, inject)
     # No direct xmlrpc function for fetching so far
     if inject is None:
         raise NotImplementedError("Direct bug fetching not implemented")
     # Process provided inject
     self._id = int(inject["id"])
     self._bug = int(inject["bug_id"])
     self._system = int(inject["bug_system_id"])
     self._testcase = TestCase(int(inject["case_id"]))
     if inject["case_run_id"] is not None:
         self._caserun = CaseRun(int(inject["case_run_id"]))
     # Index the fetched object into cache
     self._index()
Example #20
0
 def _fetch(self, inset=None):
     """ Save cache timestamp and initialize from inset if given """
     Nitrate._fetch(self)
     # Create copies of the initial set (if given)
     if inset is not None:
         log.debug("Initializing {0} for {1} from the inset".format(
             self.__class__.__name__, self._identifier))
         log.debug(pretty(inset))
         self._current = set(inset)
         self._original = set(inset)
     # Cache into container class
     if config.get_cache_level() >= config.CACHE_OBJECTS:
         self.__class__._cache[self._id] = self
     # Return True if the data are already initialized
     return inset is not None
Example #21
0
    def __init__(self, id=None, name=None):
        """ Initialize by test plan type id or name """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch data from it
        if inject:
            self._fetch(inject)
        # Initialize by name
        elif name is not None:
            self._name = name
            self._index(name)
        # Otherwise just check that the test plan type id was provided
        elif not id:
            raise NitrateError(
                    "Need either id or name to initialize the PlanType object")
Example #22
0
    def _fetch(self, inject=None):
        """ Get the missing build data """
        Nitrate._fetch(self, inject)
        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing build ID#{0} inject".format(
                    inject["build_id"]))
        # Search by build id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching build " + self.identifier)
                inject = self._server.Build.get(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find build for " + self.identifier)
        # Search by build name and product
        else:
            try:
                log.info(u"Fetching build '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Build.check_build(
                        self.name, self.product.id)
                self._id = inject["build_id"]
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("Build '{0}' not found in '{1}'".format(
                    self.name, self.product.name))
            except KeyError:
                if "args" in inject:
                    log.debug(inject["args"])
                raise NitrateError("Build '{0}' not found in '{1}'".format(
                    self.name, self.product.name))

        # Initialize data from the inject and index into cache
        log.debug("Initializing Build ID#{0}".format(inject["build_id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["build_id"]
        self._name = inject["name"]
        self._product = Product(
                {"id": inject["product_id"], "name": inject["product"]})
        self._index("{0}---in---{1}".format(self.name, self.product.name))
Example #23
0
    def __init__(self, id=None, name=None):
        """ Initialize by test plan type id or name """

        # Initialize (unless already done)
        id, name, inject, initialized = self._is_initialized(id or name)
        if initialized: return
        Nitrate.__init__(self, id)

        # If inject given, fetch data from it
        if inject:
            self._fetch(inject)
        # Initialize by name
        elif name is not None:
            self._name = name
            self._index(name)
        # Otherwise just check that the test plan type id was provided
        elif not id:
            raise NitrateError(
                    "Need either id or name to initialize the PlanType object")
Example #24
0
    def _fetch(self, inject=None):
        """ Get the missing build data """
        Nitrate._fetch(self, inject)
        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing build ID#{0} inject".format(
                    inject["build_id"]))
        # Search by build id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching build " + self.identifier)
                inject = self._server.Build.get(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find build for " + self.identifier)
        # Search by build name and product
        else:
            try:
                log.info(u"Fetching build '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Build.check_build(
                        self.name, self.product.id)
                self._id = inject["build_id"]
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("Build '{0}' not found in '{1}'".format(
                    self.name, self.product.name))
            except KeyError:
                if "args" in inject:
                    log.debug(inject["args"])
                raise NitrateError("Build '{0}' not found in '{1}'".format(
                    self.name, self.product.name))

        # Initialize data from the inject and index into cache
        log.debug("Initializing Build ID#{0}".format(inject["build_id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["build_id"]
        self._name = inject["name"]
        self._product = Product(
                {"id": inject["product_id"], "name": inject["product"]})
        self._index("{0}---in---{1}".format(self.name, self.product.name))
Example #25
0
    def __init__(self, id=None, bug=None, system=1, **kwargs):
        """
        Initialize the bug

        Provide external bug id, optionally bug system (Bugzilla by default).
        """

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id, prefix="BUG")

        # If inject given, fetch bug data from it
        if inject:
            self._fetch(inject)
        # Initialized by bug id and system id
        elif bug is not None and system is not None:
            self._bug = bug
            self._system = system
        # Otherwise just check that the id was provided
        elif id is None:
            raise NitrateError("Need bug id to initialize the Bug object.")
Example #26
0
    def _fetch(self, inject=None):
        """ Fetch version data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Processing Version ID#{0} inject".format(inject["id"]))
        # Search by version id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching version {0}".format(self.identifier))
                inject = self._server.Product.filter_versions(
                        {'id': self.id})[0]
            except IndexError:
                raise NitrateError(
                        "Cannot find version for {0}".format(self.identifier))
        # Search by product and name
        else:
            try:
                log.info(u"Fetching version '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Product.filter_versions(
                        {'product': self.product.id, 'value': self.name})[0]
            except IndexError:
                raise NitrateError(
                        "Cannot find version for '{0}'".format(self.name))
        # Initialize data from the inject and index into cache
        log.debug("Initializing Version ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["value"]
        self._product = Product(inject["product_id"])
        # Index by product name & version name (if product is cached)
        if self.product._name is not NitrateNone:
            self._index("{0}---in---{1}".format(self.name, self.product.name))
        # Otherwise index by id only
        else:
            self._index()
Example #27
0
    def _fetch(self, inject=None):
        """ Fetch version data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Processing Version ID#{0} inject".format(inject["id"]))
        # Search by version id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching version {0}".format(self.identifier))
                inject = self._server.Product.filter_versions(
                        {'id': self.id})[0]
            except IndexError:
                raise NitrateError(
                        "Cannot find version for {0}".format(self.identifier))
        # Search by product and name
        else:
            try:
                log.info(u"Fetching version '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Product.filter_versions(
                        {'product': self.product.id, 'value': self.name})[0]
            except IndexError:
                raise NitrateError(
                        "Cannot find version for '{0}'".format(self.name))
        # Initialize data from the inject and index into cache
        log.debug("Initializing Version ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["value"]
        self._product = Product(inject["product_id"])
        # Index by product name & version name (if product is cached)
        if self.product._name is not NitrateNone:
            self._index("{0}---in---{1}".format(self.name, self.product.name))
        # Otherwise index by id only
        else:
            self._index()
Example #28
0
    def __init__(self, id=None, bug=None, system=1, **kwargs):
        """
        Initialize the bug

        Provide external bug id, optionally bug system (Bugzilla by default).
        """

        # Initialize (unless already done)
        id, ignore, inject, initialized = self._is_initialized(id)
        if initialized: return
        Nitrate.__init__(self, id, prefix="BUG")

        # If inject given, fetch bug data from it
        if inject:
            self._fetch(inject)
        # Initialized by bug id and system id
        elif bug is not None and system is not None:
            self._bug = bug
            self._system = system
        # Otherwise just check that the id was provided
        elif id is None:
            raise NitrateError("Need bug id to initialize the Bug object.")
Example #29
0
def multicall_end():
    """ Execute xmlrpc call queue and exit MultiCall mode """
    log.info("Ending multicall session, sending to the server...")
    response = Nitrate._multicall_proxy()
    log.data("Server response:")
    entries = 0
    for entry in response:
        log.data(pretty(entry))
        entries += 1
    Nitrate._multicall_proxy = None
    Nitrate._requests += 1
    log.info("Multicall session finished, {0} completed".format(
            listed(entries, "update")))
    return response
Example #30
0
def multicall_end():
    """ Execute xmlrpc call queue and exit MultiCall mode """
    log.info("Ending multicall session, sending to the server...")
    response = Nitrate._multicall_proxy()
    log.data("Server response:")
    entries = 0
    for entry in response:
        log.data(pretty(entry))
        entries += 1
    Nitrate._multicall_proxy = None
    Nitrate._requests += 1
    log.info("Multicall session finished, {0} completed".format(
            listed(entries, "update")))
    return response
Example #31
0
    def _fetch(self, inject=None):
        """ Get the missing category data """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing category ID#{0} inject".format(inject["id"]))
        # Search by category id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching category {0}".format(self.identifier))
                inject = self._server.Product.get_category(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find category for " + self.identifier)
        # Search by category name and product
        else:
            try:
                log.info(u"Fetching category '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Product.check_category(
                        self.name, self.product.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("Category '{0}' not found in"
                        " '{1}'".format(self.name, self.product.name))

        # Initialize data from the inject and index into cache
        log.debug("Initializing category ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["name"]
        self._product = Product(
                {"id": inject["product_id"], "name": inject["product"]})
        self._index("{0}---in---{1}".format(self.name, self.product.name))
Example #32
0
    def _fetch(self, inject=None):
        """ Get the missing category data """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.info("Processing category ID#{0} inject".format(inject["id"]))
        # Search by category id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching category {0}".format(self.identifier))
                inject = self._server.Product.get_category(self.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError(
                        "Cannot find category for " + self.identifier)
        # Search by category name and product
        else:
            try:
                log.info(u"Fetching category '{0}' of '{1}'".format(
                        self.name, self.product.name))
                inject = self._server.Product.check_category(
                        self.name, self.product.id)
            except xmlrpclib.Fault as error:
                log.debug(error)
                raise NitrateError("Category '{0}' not found in"
                        " '{1}'".format(self.name, self.product.name))

        # Initialize data from the inject and index into cache
        log.debug("Initializing category ID#{0}".format(inject["id"]))
        log.data(pretty(inject))
        self._inject = inject
        self._id = inject["id"]
        self._name = inject["name"]
        self._product = Product(
                {"id": inject["product_id"], "name": inject["product"]})
        self._index("{0}---in---{1}".format(self.name, self.product.name))
Example #33
0
    def _fetch(self, inject=None):
        """ Fetch tag data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Initializing Tag ID#{0}".format(inject["id"]))
            log.data(pretty(inject))
            self._id = inject["id"]
            self._name = inject["name"]
        # Search by tag id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching tag " + self.identifier)
                inject = self._server.Tag.get_tags({'ids': [self.id]})
                log.debug("Initializing tag " + self.identifier)
                log.data(pretty(inject))
                self._inject = inject
                self._name = inject[0]["name"]
            except IndexError:
                raise NitrateError(
                        "Cannot find tag for {0}".format(self.identifier))
        # Search by tag name
        else:
            try:
                log.info(u"Fetching tag '{0}'".format(self.name))
                inject = self._server.Tag.get_tags({'names': [self.name]})
                log.debug(u"Initializing tag '{0}'".format(self.name))
                log.data(pretty(inject))
                self._inject = inject
                self._id = inject[0]["id"]
            except IndexError:
                raise NitrateError(
                        "Cannot find tag '{0}'".format(self.name))
        # Index the fetched object into cache
        self._index(self.name)
Example #34
0
    def _fetch(self, inject=None):
        """ Fetch product data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Initializing Product ID#{0}".format(inject["id"]))
            log.data(pretty(inject))
            self._id = inject["id"]
            self._name = inject["name"]
        # Search by product id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching product " + self.identifier)
                inject = self._server.Product.filter({'id': self.id})[0]
                log.debug("Initializing product " + self.identifier)
                log.data(pretty(inject))
                self._inject = inject
                self._name = inject["name"]
            except IndexError:
                raise NitrateError(
                        "Cannot find product for " + self.identifier)
        # Search by product name
        else:
            try:
                log.info(u"Fetching product '{0}'".format(self.name))
                inject = self._server.Product.filter({'name': self.name})[0]
                log.debug(u"Initializing product '{0}'".format(self.name))
                log.data(pretty(inject))
                self._inject = inject
                self._id = inject["id"]
            except IndexError:
                raise NitrateError(
                        "Cannot find product for '{0}'".format(self.name))
        # Index the fetched object into cache
        self._index(self.name)
Example #35
0
    def _fetch(self, inject=None):
        """ Fetch product data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Initializing Product ID#{0}".format(inject["id"]))
            log.data(pretty(inject))
            self._id = inject["id"]
            self._name = inject["name"]
        # Search by product id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching product " + self.identifier)
                inject = self._server.Product.filter({'id': self.id})[0]
                log.debug("Initializing product " + self.identifier)
                log.data(pretty(inject))
                self._inject = inject
                self._name = inject["name"]
            except IndexError:
                raise NitrateError(
                        "Cannot find product for " + self.identifier)
        # Search by product name
        else:
            try:
                log.info(u"Fetching product '{0}'".format(self.name))
                inject = self._server.Product.filter({'name': self.name})[0]
                log.debug(u"Initializing product '{0}'".format(self.name))
                log.data(pretty(inject))
                self._inject = inject
                self._id = inject["id"]
            except IndexError:
                raise NitrateError(
                        "Cannot find product for '{0}'".format(self.name))
        # Index the fetched object into cache
        self._index(self.name)
Example #36
0
    def _fetch(self, inject=None):
        """ Fetch tag data from the server """
        Nitrate._fetch(self, inject)

        # Directly fetch from the initial object dict
        if inject is not None:
            log.debug("Initializing Tag ID#{0}".format(inject["id"]))
            log.data(pretty(inject))
            self._id = inject["id"]
            self._name = inject["name"]
        # Search by tag id
        elif self._id is not NitrateNone:
            try:
                log.info("Fetching tag " + self.identifier)
                inject = self._server.Tag.get_tags({'ids': [self.id]})
                log.debug("Initializing tag " + self.identifier)
                log.data(pretty(inject))
                self._inject = inject
                self._name = inject[0]["name"]
            except IndexError:
                raise NitrateError(
                        "Cannot find tag for {0}".format(self.identifier))
        # Search by tag name
        else:
            try:
                log.info(u"Fetching tag '{0}'".format(self.name))
                inject = self._server.Tag.get_tags({'names': [self.name]})
                log.debug(u"Initializing tag '{0}'".format(self.name))
                log.data(pretty(inject))
                self._inject = inject
                self._id = inject[0]["id"]
            except IndexError:
                raise NitrateError(
                        "Cannot find tag '{0}'".format(self.name))
        # Index the fetched object into cache
        self._index(self.name)
Example #37
0
 def search(**query):
     """ Search for users """
     return [User(hash)
             for hash in Nitrate()._server.User.filter(dict(query))]
Example #38
0
def multicall_start():
    """ Enter MultiCall mode and queue following xmlrpc calls """
    log.info("Starting multicall session, gathering updates...")
    Nitrate._multicall_proxy = xmlrpclib.MultiCall(Nitrate()._server)
Example #39
0
 def search(**query):
     """ Search for products """
     return [Product(hash["id"])
             for hash in Nitrate()._server.Product.filter(dict(query))]
Example #40
0
 def search(**query):
     """ Search for components """
     return [Component(hash) for hash in
             Nitrate()._server.Product.filter_components(dict(query))]