Ejemplo n.º 1
0
 def owner(self, argv):
     """owner [<name>]
 Set the owner of this container to <name>, of possible.
 The special name "delete" will remove ownership."""
     name = argv[1] if len(argv) > 1 else None
     if not _user.is_superuser:
         self._ui.warning("Only superuser accounts can change ownership")
         return
     if name is None:
         current = self._obj.user
         choices = models.get_choices(_session, models.Config, "user", "username")
         choices.insert(0, (0, "Nobody"))
         chosen_id = self._ui.choose_key(dict(choices), current.id if current is not None else 0, "%Iuser%N")
         if chosen_id == 0:
             config.Container(_session, self._obj, user=_user).set_owner(None)
         else:
             relmodel = models.Config.user.property.mapper.class_
             related = _session.query(relmodel).get(chosen_id)
             config.Container(_session, self._obj, user=_user).set_owner(related)
     else:
         if name.startswith("delete"):
             config.Container(_session, self._obj, user=_user).set_owner(None)
         else:
             user = models.User.get_by_username(_session, name)
             if user:
                 config.Container(_session, self._obj, user=_user).set_owner(user)
             else:
                 self._ui.error("No such user.")
Ejemplo n.º 2
0
def do_config(session):
    rn = models.create(models.Config,
                       name="root",
                       user=None,
                       parent=None,
                       value=aid.NULL)
    session.add(rn)
    flags = models.create(models.Config,
                          name="flags",
                          user=None,
                          container=rn,
                          value=aid.NULL)
    session.add(flags)
    session.commit()
    root = config.Container(session, rn)
    flags = config.Container(session, flags)
    flags.VERBOSE = 0  # levels of verbosity
    flags.DEBUG = 0  # levels of debugging
    flags.INTERACTIVE = False  # Don't run interactive tests also, by default
    root["logbasename"] = "testrun.log"
    root["logfiledir"] = "/var/tmp"
    root["reportbasename"] = "-"
    root["resultsdirbase"] = '/var/www/localhost/htdocs/testresults'
    root["documentroot"] = "/var/www/localhost"
    # this one, at least, will have to be changed by installer.
    root["baseurl"] = "http://localhost"

    ui = root.add_container("userinterfaces")
    ui.default = ("UI.UserInterface", "IO.ConsoleIO", "UI.DefaultTheme")
    ui.console = ("UI.UserInterface", "IO.ConsoleIO", "UI.DefaultTheme")

    reports = root.add_container("reports")
    reports.default = ("StandardReport", "-", "text/ansi")
    reports.ansi = ("StandardReport", "-", "text/ansi; charset=utf8")
    reports.database = ("pycopia.reports.database.DatabaseReport", )
    reports.email = ("pycopia.reports.Email.EmailReport", "text/html", None)
    reports.html = ("StandardReport", "$username-$runnertimestamp",
                    "text/html")
    reports.full = [("StandardReport", "-", "text/ansi; charset=utf8"),
                    ("StandardReport", "$username-$runnertimestamp",
                     "text/html")]
    reports.production = [
        ("StandardReport", "-", "text/ansi; charset=utf8"),
        ("StandardReport", "$username-$runnertimestamp", "text/html"),
        ("pycopia.reports.database.DatabaseReport", ),
    ]
    controllers = root.add_container("controllers")
    selenium = root.add_container("selenium")
    selenium.host = "localhost"
    selenium.port = 4444
    selenium.browser = "firefox"
    session.commit()
Ejemplo n.º 3
0
 def mkdir(self, argv):
     """mkdir <name>
 Make a new container here."""
     name = argv[1]
     container = config.Container(_session, self._obj, user=_user)
     try:
         cont = container.add_container(name)
     except config.ConfigError as err:
         self._ui.error(err)
Ejemplo n.º 4
0
 def __getattribute__(self, key):
     if key == "__dict__":
         return object.__getattribute__(self, key)
     try:
         # check the local cache first, overrides persistent storage
         return self.__dict__["_cache"].__getitem__(key)
     except KeyError:
         pass
     try:
         return super(RootContainer, self).__getattribute__(key)
     except AttributeError:
         node = self.__dict__["node"]
         session = self.__dict__["session"]
         try:
             item = config.get_item(session, node, key)
             if item.value is aid.NULL:
                 return config.Container(session, item)
             else:
                 return item.value
         except config.NoResultFound as err:
             raise AttributeError(
                 "RootContainer: No attribute or key '%s' found: %s" %
                 (key, err))