Пример #1
0
    def get_packages():
        # retrieve list of installed software
        c = FileManager.capture_output(["reg", "query", "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "/s"])

        # parse install locations out of this
        packages = []
        for match in re.finditer(r"InstallLocation\s*REG_SZ[ \t]*([a-zA-Z][^\n]+)\r\n", c):
            install_location = match.group(1)
            packages.append(Package(install_location))

        return packages
Пример #2
0
    def db_exists(dbname):
        '''helper to return boolean indicating if the db w/ the specified name exists'''
        mysql_password = snap.config.options.service_options['mysql_password']

        # retrieve list of db names from mysql
        c = FileManager.capture_output([Mysql.MYSQL_CMD, "-e", "show databases", "-u", "root", "-p" + mysql_password])

        # determine if the specified one is among them
        has_db = len(re.findall(dbname, c))

        return has_db
Пример #3
0
    def db_exists(dbname):
        '''helper to return boolean indicating if the db w/ the specified name exists'''
        # get the env containing the postgres password
        penv = Postgresql.set_pgpassword_env()

        # retrieve list of db names from postgres
        c = FileManager.capture_output([Postgresql.PSQL_CMD, "--username", "postgres", "-t", "-c", "select datname from pg_database"], env=penv)

        # determine if the specified one is among them
        has_db = len(re.findall(dbname, c))

        return has_db
Пример #4
0
    def db_exists(dbname):
        '''helper to return boolean indicating if the db w/ the specified name exists'''
        mysql_password = snap.config.options.service_options['mysql_password']

        # retrieve list of db names from mysql
        c = FileManager.capture_output([
            Mysql.MYSQL_CMD, "-e", "show databases", "-u", "root",
            "-p" + mysql_password
        ])

        # determine if the specified one is among them
        has_db = len(re.findall(dbname, c))

        return has_db
Пример #5
0
    def get_packages():
        # retrieve list of installed software
        c = FileManager.capture_output([
            "reg", "query",
            "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "/s"
        ])

        # parse install locations out of this
        packages = []
        for match in re.finditer(
                r"InstallLocation\s*REG_SZ[ \t]*([a-zA-Z][^\n]+)\r\n", c):
            install_location = match.group(1)
            packages.append(Package(install_location))

        return packages
Пример #6
0
    def db_exists(dbname):
        '''helper to return boolean indicating if the db w/ the specified name exists'''
        # get the env containing the postgres password
        penv = Postgresql.set_pgpassword_env()

        # retrieve list of db names from postgres
        c = FileManager.capture_output([
            Postgresql.PSQL_CMD, "--username", "postgres", "-t", "-c",
            "select datname from pg_database"
        ],
                                       env=penv)

        # determine if the specified one is among them
        has_db = len(re.findall(dbname, c))

        return has_db
Пример #7
0
    def backup(self, basedir, include=[], exclude=[]):
        """backup the files modified outside the apt package system"""

        if snap.config.options.log_level_at_least('verbose'):
            snap.callback.snapcallback.message("Backing up files on windows")

        # get list of hard drives
        if len(include) == 0:
            drives = []
            c = FileManager.capture_output(["fsutil", "fsinfo", "drives"])
            drives = c.split()[1:]
       
            # loop through each drive and determine which are available
            for drive in drives:
                include_drive = True
                try:
                    os.listdir(drive)
                except WindowsError, e:
                    include_drive = False
                if include_drive:
                    include.append(drive)
Пример #8
0
    def backup(self, basedir, include=[], exclude=[]):
        """backup the files modified outside the apt package system"""

        if snap.config.options.log_level_at_least('verbose'):
            snap.callback.snapcallback.message("Backing up files on windows")

        # get list of hard drives
        if len(include) == 0:
            drives = []
            c = FileManager.capture_output(["fsutil", "fsinfo", "drives"])
            drives = c.split()[1:]

            # loop through each drive and determine which are available
            for drive in drives:
                include_drive = True
                try:
                    os.listdir(drive)
                except WindowsError, e:
                    include_drive = False
                if include_drive:
                    include.append(drive)
Пример #9
0
 def testCaptureOutputWithStdout(self):
     out = FileManager.capture_output(['expr', '1', '/', '0'])
     self.assertEqual("expr: division by zero\n", out)
Пример #10
0
 def testCaptureOutput(self):
     out = FileManager.capture_output(['echo', 'yo'])
     self.assertEqual("yo\n", out)
Пример #11
0
 def testCaptureOutputWithStdout(self):
     out = FileManager.capture_output(['expr', '1', '/', '0'])
     self.assertEqual("expr: division by zero\n", out)
Пример #12
0
 def testCaptureOutput(self):
     out = FileManager.capture_output(['echo', 'yo'])
     self.assertEqual("yo\n", out)