Ejemplo n.º 1
0
 def createWorkspace(self, name, desc, dbtype=DBTYPE.COUCHDB):
     workspace = Workspace(name, desc)
     try:
         dbConnector = self.dbManager.createDb(name, dbtype)
     except restkit.Unauthorized:
         raise WorkspaceException(
             (
                 "You're not authorized to create workspaces\n"
                 "Make sure you're an admin and add your credentials"
                 "to your user configuration "
                 "file in $HOME/.faraday/config/user.xml\n"
                 "For example: "
                 "<couch_uri>http://john:[email protected]:5984</couch_uri>"
             )
         )
     except Exception as e:
         raise WorkspaceException(str(e))
     if dbConnector:
         self.closeWorkspace()
         self.mappersManager.createMappers(dbConnector)
         self.mappersManager.save(workspace)
         self.setActiveWorkspace(workspace)
         notification_center.workspaceChanged(workspace, self.getWorkspaceType(name))
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         return workspace
     return False
Ejemplo n.º 2
0
 def openWorkspace(self, name):
     """Open a workspace by name. Returns the workspace. Raises an
     WorkspaceException if something went wrong along the way.
     """
     if name not in self.getWorkspacesNames():
         raise WorkspaceException("Workspace %s wasn't found" % name)
     self.closeWorkspace()
     try:
         dbConnector = self.dbManager.getConnector(name)
     except restkit.Unauthorized:
         raise WorkspaceException(
             (
                 "You're not authorized to access this workspace\n"
                 "Add your credentials to your user configuration "
                 "file in $HOME/.faraday/config/user.xml\n"
                 "For example: "
                 "<couch_uri>http://john:[email protected]:5984</couch_uri>"
             )
         )
     except Exception as e:
         notification_center.CouchDBConnectionProblem(e)
         raise WorkspaceException(str(e))
     self.mappersManager.createMappers(dbConnector)
     workspace = self.mappersManager.getMapper(Workspace.__name__).find(name)
     if not workspace:
         raise WorkspaceException(
             ("Error loading workspace.\n" "You should try opening faraday " "with the '--update' option")
         )
     self.setActiveWorkspace(workspace)
     notification_center.workspaceChanged(workspace, self.getWorkspaceType(name))
     notification_center.workspaceLoad(workspace.getHosts())
     self.changesManager.watch(self.mappersManager, dbConnector)
     return workspace
Ejemplo n.º 3
0
 def createWorkspace(self, name, desc, dbtype=DBTYPE.COUCHDB):
     workspace = Workspace(name, desc)
     try:
         dbConnector = self.dbManager.createDb(name, dbtype)
     except restkit.Unauthorized:
         raise WorkspaceException(
             ("You're not authorized to create workspaces\n"
              "Make sure you're an admin and add your credentials"
              "to your user configuration "
              "file in $HOME/.faraday/config/user.xml\n"
              "For example: "
              "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
     except Exception as e:
         raise WorkspaceException(str(e))
     if dbConnector:
         self.closeWorkspace()
         self.mappersManager.createMappers(dbConnector)
         self.mappersManager.save(workspace)
         self.setActiveWorkspace(workspace)
         notification_center.workspaceChanged(workspace,
                                              self.getWorkspaceType(name))
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         return workspace
     return False
Ejemplo n.º 4
0
 def openWorkspace(self, name):
     """Open a workspace by name. Returns the workspace. Raises an
     WorkspaceException if something went wrong along the way.
     """
     if name not in self.getWorkspacesNames():
         raise WorkspaceException("Workspace %s wasn't found" % name)
     self.closeWorkspace()
     try:
         dbConnector = self.dbManager.getConnector(name)
     except restkit.Unauthorized:
         raise WorkspaceException(
             ("You're not authorized to access this workspace\n"
              "Add your credentials to your user configuration "
              "file in $HOME/.faraday/config/user.xml\n"
              "For example: "
              "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
     except Exception as e:
         notification_center.CouchDBConnectionProblem(e)
         raise WorkspaceException(str(e))
     self.mappersManager.createMappers(dbConnector)
     workspace = self.mappersManager.getMapper(
         Workspace.__name__).find(name)
     if not workspace:
         raise WorkspaceException(("Error loading workspace.\n"
                                   "You should try opening faraday "
                                   "with the '--update' option"))
     self.setActiveWorkspace(workspace)
     notification_center.workspaceChanged(workspace,
                                          self.getWorkspaceType(name))
     notification_center.workspaceLoad(workspace.getHosts())
     self.changesManager.watch(self.mappersManager, dbConnector)
     return workspace
Ejemplo n.º 5
0
 def createWorkspace(self,
                     name,
                     desc,
                     start_date=int(time.time() * 1000),
                     finish_date=int(time.time() * 1000),
                     customer=""):
     # XXX: DEPRECATE NEXT LINE
     workspace = Workspace(name, desc)
     try:
         create_workspace(name,
                          description=desc,
                          start_date=start_date,
                          finish_date=finish_date,
                          customer=customer)
     except Unauthorized:
         raise WorkspaceException(
             ("You're not authorized to create workspaces\n"
              "Make sure you're an admin and add your credentials"
              "to your user configuration "
              "file in $HOME/.faraday/config/user.xml\n"
              "For example: "
              "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
     except Exception as e:
         raise WorkspaceException(str(e))
     self.mappersManager.createMappers(name)
     self.setActiveWorkspace(workspace)
     notification_center.workspaceChanged(workspace)
     return name
Ejemplo n.º 6
0
 def createWorkspace(self, name, desc, dbtype=DBTYPE.FS):
     workspace = Workspace(name, desc)
     dbConnector = self.dbManager.createDb(name, dbtype)
     if dbConnector:
         self.closeWorkspace()
         self.mappersManager.createMappers(dbConnector)
         self.mappersManager.save(workspace)
         self.setActiveWorkspace(workspace)
         notification_center.workspaceChanged(workspace)
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         self.reportsManager.watch(name)
         return workspace
     return False
Ejemplo n.º 7
0
 def openWorkspace(self, name):
     if name in self.getWorkspacesNames():
         self.closeWorkspace()
         dbConnector = self.dbManager.getConnector(name)
         self.mappersManager.createMappers(dbConnector)
         workspace = self.mappersManager.getMapper(Workspace.__name__).find(name)
         self.setActiveWorkspace(workspace)
         CONF.setLastWorkspace(name)
         CONF.saveConfig()
         notification_center.workspaceChanged(workspace)
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         self.reportsManager.watch(name)
         return workspace
     return None
Ejemplo n.º 8
0
 def createWorkspace(self, name, desc, dbtype=DBTYPE.FS):
     workspace = Workspace(name, desc)
     dbConnector = self.dbManager.createDb(name, dbtype)
     if dbConnector:
         self.closeWorkspace()
         self.mappersManager.createMappers(dbConnector)
         self.mappersManager.save(workspace)
         self.setActiveWorkspace(workspace)
         CONF.setLastWorkspace(name)
         CONF.saveConfig()
         notification_center.workspaceChanged(workspace)
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         self.reportsManager.watch(name)
         return workspace
     return False
Ejemplo n.º 9
0
 def openWorkspace(self, name):
     if name in self.getWorkspacesNames():
         self.closeWorkspace()
         dbConnector = self.dbManager.getConnector(name)
         self.mappersManager.createMappers(dbConnector)
         workspace = self.mappersManager.getMapper(Workspace.__name__).find(name)
         if not workspace:
             notification_center.showDialog(
                 "Error loading workspace.\nYou should try opening faraday with the '--update' option",
                 level="ERROR")
             return self.openDefaultWorkspace()
         self.setActiveWorkspace(workspace)
         CONF.setLastWorkspace(name)
         CONF.saveConfig()
         notification_center.workspaceChanged(workspace)
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         self.reportsManager.watch(name)
         return workspace
     return None
Ejemplo n.º 10
0
 def openWorkspace(self, name):
     if name in self.getWorkspacesNames():
         self.closeWorkspace()
         dbConnector = self.dbManager.getConnector(name)
         self.mappersManager.createMappers(dbConnector)
         workspace = self.mappersManager.getMapper(Workspace.__name__).find(name)
         if not workspace:
             notification_center.showDialog(
                 "Error loading workspace.\nYou should try opening faraday with the '--update' option",
                 level="ERROR")
             return self.openDefaultWorkspace()
         self.setActiveWorkspace(workspace)
         CONF.setLastWorkspace(name)
         CONF.saveConfig()
         notification_center.workspaceChanged(workspace,self.getWorkspaceType(name))
         notification_center.workspaceLoad(workspace.getHosts())
         self.changesManager.watch(self.mappersManager, dbConnector)
         self.reportsManager.watch(name)
         return workspace
     return None
Ejemplo n.º 11
0
 def createWorkspace(self, name, desc, start_date=int(time.time() * 1000),
                     finish_date=int(time.time() * 1000), customer=""):
     # XXX: DEPRECATE NEXT LINE
     workspace = Workspace(name, desc)
     try:
         create_workspace(name, description=desc, start_date=start_date,
                          finish_date=finish_date, customer=customer)
     except Unauthorized:
         raise WorkspaceException(
             ("You're not authorized to create workspaces\n"
              "Make sure you're an admin and add your credentials"
              "to your user configuration "
              "file in $HOME/.faraday/config/user.xml\n"
              "For example: "
              "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
     except Exception as e:
         raise WorkspaceException(str(e))
     self.closeWorkspace()
     self.mappersManager.createMappers(name)
     self.setActiveWorkspace(workspace)
     notification_center.workspaceChanged(workspace)
     return name
Ejemplo n.º 12
0
    def openWorkspace(self, name):
        """Open a workspace by name. Returns the workspace. Raises an
        WorkspaceException if something went wrong along the way.
        """
        if name not in get_workspaces_names():
            raise WorkspaceException("Workspace %s wasn't found" % name)

        try:
            workspace = get_workspace(name)
        except Unauthorized:
            raise WorkspaceException(
                ("You're not authorized to access this workspace\n"
                 "Add your credentials to your user configuration "
                 "file in $HOME/.faraday/config/user.xml\n"
                 "For example: "
                 "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
        except Exception as e:
            notification_center.DBConnectionProblem(e)
            raise WorkspaceException(str(e))
        self.mappersManager.createMappers(name)
        self.setActiveWorkspace(workspace)
        notification_center.workspaceChanged(workspace)
        return workspace
Ejemplo n.º 13
0
 def openWorkspace(self, name):
     """Open a workspace by name. Returns the workspace. Raises an
     WorkspaceException if something went wrong along the way.
     """
     if name not in get_workspaces_names():
         raise WorkspaceException(
             "Workspace %s wasn't found" % name)
     self.closeWorkspace()
     try:
         workspace = get_workspace(name)
     except Unauthorized:
         raise WorkspaceException(
             ("You're not authorized to access this workspace\n"
              "Add your credentials to your user configuration "
              "file in $HOME/.faraday/config/user.xml\n"
              "For example: "
              "<couch_uri>http://john:[email protected]:5984</couch_uri>"))
     except Exception as e:
         notification_center.CouchDBConnectionProblem(e)
         raise WorkspaceException(str(e))
     self.mappersManager.createMappers(name)
     self.setActiveWorkspace(workspace)
     notification_center.workspaceChanged(workspace)
     return workspace