Esempio n. 1
0
    def run(self, workdir=None):
        """
        Runs the installer
        :param workdir: The working directory to use to put tarball and uncompressed files.
        """
        with cd(workdir):
            self.tarball = self.download(self.url)
            self.pkg_name = self.unzip(self.tarball)

            dll_file = os.path.join(workdir, self.pkg_name, python_isa, "WinDivert.dll")
            sys_file = os.path.join(workdir, self.pkg_name, system_isa, "WinDivert%d.sys" % (
                64 if system_isa == "amd64" else 32))

            if not os.path.exists(self.inst_dir):
                sys.stdout.write("Creating driver install directory %s" % self.inst_dir)
                os.makedirs(self.inst_dir)

            for f in (dll_file, sys_file):
                sys.stdout.write("Copying %s to %s\n" % (f, self.inst_dir))
                shutil.copy(f, self.inst_dir)
                os.chmod(os.path.join(self.inst_dir, os.path.basename(f)), 0755)

            sys.stdout.write("Trying to register driver...\n")
            self.check_driver_path(os.path.join(self.inst_dir, "WinDivert.dll"))

            sys.stdout.write("Cleaning paths...\n")
            self.clean()
Esempio n. 2
0
 def register(self):
     """
     An utility method to register the driver the first time.
     """
     with cd(os.path.dirname(self.dll_path)):
         handle = self.open_handle("false")
         handle.close()
Esempio n. 3
0
    def run(self):
        from pydivert.tests import run_test_suites

        for env_name, env_value in self.extra_env.items():
            os.environ[env_name] = str(env_value)

        with cd(os.path.join(os.path.join(workdir, "pydivert", "tests"))):
            run_test_suites()
Esempio n. 4
0
    def run(self):
        from pydivert.tests import run_test_suites

        for env_name, env_value in self.extra_env.items():
            os.environ[env_name] = str(env_value)

        with cd(os.path.join(os.path.join(workdir, "pydivert", "tests"))):
            run_test_suites()
Esempio n. 5
0
 def test_download(self):
     """
     Tests the download of a package through WinDivertInstaller class
     :return:
     """
     with cd(self.work_dir):
         local_filename = WinDivertInstaller.download(url="http://somehost/somedir/%s" % self.tarball)
         self.assertEquals(local_filename, self.tarball)
         self.assertTrue(os.path.exists(os.path.join(self.work_dir, self.tarball)))
Esempio n. 6
0
 def test_download(self):
     """
     Tests the download of a package through WinDivertInstaller class
     :return:
     """
     with cd(self.work_dir):
         local_filename = WinDivertInstaller.download(
             url="http://somehost/somedir/%s" % self.tarball)
         self.assertEquals(local_filename, self.tarball)
         self.assertTrue(
             os.path.exists(os.path.join(self.work_dir, self.tarball)))
Esempio n. 7
0
 def test_unzip(self):
     """
     Tests the uncompressing method of WinDivertInstaller class
     :return:
     """
     self.test_download()
     with cd(self.work_dir):
         expected_dir = os.path.join(self.work_dir, os.path.splitext(self.tarball)[0])
         extracted_dir = WinDivertInstaller.unzip(os.path.join(self.work_dir, self.tarball))
         self.assertEquals(extracted_dir, expected_dir)
         self.assertTrue(os.path.exists(expected_dir))
Esempio n. 8
0
 def test_unzip(self):
     """
     Tests the uncompressing method of WinDivertInstaller class
     :return:
     """
     self.test_download()
     with cd(self.work_dir):
         expected_dir = os.path.join(self.work_dir,
                                     os.path.splitext(self.tarball)[0])
         extracted_dir = WinDivertInstaller.unzip(
             os.path.join(self.work_dir, self.tarball))
         self.assertEquals(extracted_dir, expected_dir)
         self.assertTrue(os.path.exists(expected_dir))
Esempio n. 9
0
    def run(self, workdir=None):
        """
        Runs the installer
        :param workdir: The working directory to use to put tarball and uncompressed files.
        """
        with cd(workdir):
            self.tarball = self.download(self.url)
            self.pkg_name = self.unzip(self.tarball)

            dll_file = os.path.join(workdir, self.pkg_name, python_isa, "WinDivert.dll")
            sys_file = os.path.join(workdir, self.pkg_name, system_isa, "WinDivert%d.sys" % (
                64 if system_isa == "amd64" else 32))

            for f in (dll_file, sys_file):
                sys.stdout.write("Copying %s to %s\n" % (f, self.inst_dir))
                shutil.copy(f, self.inst_dir)

            sys.stdout.write("Trying to register driver...\n")
            self.check_driver_path(os.path.join(self.inst_dir, "WinDivert.dll"))

            sys.stdout.write("Cleaning paths...\n")
            self.clean()