Esempio n. 1
0
    def test_boundary(self):
        """
         Test behavior around 0.4.14.999 boundary
        """

        self.assertEquals(utils_version.to_canonical('0.004014998'),
                          '0.4.14-rc998')
        self.assertEquals(utils_version.to_canonical('0.004014999'), '0.4.14')
        self.assertEquals(utils_version.to_canonical('0.004015000'),
                          '0.4.15.0')
        self.assertEquals(utils_version.to_canonical('0.004015999'),
                          '0.4.15.999')

        self.assertEquals(utils_version.to_numeric('0.4.14-rc998'),
                          '0.004014998')
        self.assertEquals(utils_version.to_numeric('0.4.14'), '0.004014999')
        self.assertEquals(utils_version.to_numeric('0.4.15.0'), '0.004015000')
        self.assertEquals(utils_version.to_numeric('0.4.15.999'),
                          '0.004015999')
Esempio n. 2
0
    def test_double_conversion(self):
        """
         Convert from canonical to numeric and then again to canonical
         (and viceversa) to make sure that we get what is expected.
        """

        # canonical -> numeric -> canonical
        self.assertEquals(
            utils_version.to_canonical(
                utils_version.to_numeric("133.35.71.19")), "133.35.71.19")

        # Same as above but check for -rc999 (legacy check)
        self.assertEquals(
            utils_version.to_canonical(
                utils_version.to_numeric("0.3.71-rc999")), "0.3.71")

        # numeric -> canonical -> numeric
        self.assertEquals(
            utils_version.to_numeric(
                utils_version.to_canonical("133.035071019")), "133.035071019")
Esempio n. 3
0
    def test_double_conversion(self):

        """
         Convert from canonical to numeric and then again to canonical
         (and viceversa) to make sure that we get what is expected.
        """

        # canonical -> numeric -> canonical
        self.assertEquals(utils_version.to_canonical(
          utils_version.to_numeric("133.35.71.19")),
          "133.35.71.19")

        # Same as above but check for -rc999 (legacy check)
        self.assertEquals(utils_version.to_canonical(
          utils_version.to_numeric("0.3.71-rc999")),
          "0.3.71")

        # numeric -> canonical -> numeric
        self.assertEquals(utils_version.to_numeric(
          utils_version.to_canonical("133.035071019")),
          "133.035071019")
Esempio n. 4
0
    def install(self, ctx, body):
        ''' Install new version on Windows '''

        # Make file names

        versiondir = utils_path.append(self.basedir, ctx['vinfo'], False)
        if not versiondir:
            raise RuntimeError("updater_win32: append() path failed")

        exefile = utils_path.join(versiondir, 'neubotw.exe')
        uninst = utils_path.join(versiondir, 'uninstall.exe')

        cmdline = '"%s" start' % exefile
        cmdline_k = '"%s" start -k' % exefile

        #
        # Overwrite the version of Neubot that is executed when
        # the user logs in.
        #
        regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
          "Software\Microsoft\Windows\CurrentVersion\Run", 0,
          _winreg.KEY_WRITE)
        _winreg.SetValueEx(regkey, "Neubot", 0, _winreg.REG_SZ, cmdline)
        _winreg.CloseKey(regkey)

        # Update the registry to reference the new uninstaller
        regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
          "Software\Microsoft\Windows\CurrentVersion\Uninstall\Neubot", 0,
          _winreg.KEY_WRITE)
        _winreg.SetValueEx(regkey, "DisplayName", 0, _winreg.REG_SZ,
          "Neubot " + utils_version.to_canonical(ctx['vinfo']))
        _winreg.SetValueEx(regkey, "UninstallString", 0, _winreg.REG_SZ,
          uninst)
        _winreg.CloseKey(regkey)

        logging.info('updater_win32: updated win32 registry')

        #
        # Run the new version of Neubot and tell it that this
        # version should be stopped before proceeding with normal
        # startup.
        #
        # We need to close_fds, because the child process must
        # not inherit the parent handles.  If it did, the listening
        # socket is inherited, and the child process cannot open
        # its own listening socket.  The ``-k`` argument on the
        # command line instructs the child process to request this
        # process to exit.  Of course the child does that before
        # attempting to listen a new socket.
        #
        logging.info('updater_win32: about to exec: %s', cmdline_k)
        subprocess.Popen(cmdline_k, close_fds=True)
Esempio n. 5
0
    def test_boundary(self):

        """
         Test behavior around 0.4.14.999 boundary
        """

        self.assertEquals(utils_version.to_canonical('0.004014998'),
          '0.4.14-rc998')
        self.assertEquals(utils_version.to_canonical('0.004014999'),
          '0.4.14')
        self.assertEquals(utils_version.to_canonical('0.004015000'),
          '0.4.15.0')
        self.assertEquals(utils_version.to_canonical('0.004015999'),
          '0.4.15.999')

        self.assertEquals(utils_version.to_numeric('0.4.14-rc998'),
          '0.004014998')
        self.assertEquals(utils_version.to_numeric('0.4.14'),
          '0.004014999')
        self.assertEquals(utils_version.to_numeric('0.4.15.0'),
          '0.004015000')
        self.assertEquals(utils_version.to_numeric('0.4.15.999'),
          '0.004015999')
Esempio n. 6
0
    def install(self, ctx, body):
        ''' Install new version on Windows '''

        # Save tarball
        updater_utils.tarball_save(self.basedir, ctx['vinfo'], body)

        # Extract from tarball
        updater_install.install(self.basedir, ctx['vinfo'])

        # Make file names
        versiondir = utils_path.join(self.basedir, ctx['vinfo'])
        exefile = utils_path.join(versiondir, 'neubotw.exe')
        uninst = utils_path.join(versiondir, 'uninstall.exe')
        cmdline = '"%s" start' % exefile
        cmdline_k = '"%s" start -k' % exefile

        #
        # Overwrite the version of Neubot that is executed when
        # the user logs in.
        #
        regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
          "Software\Microsoft\Windows\CurrentVersion\Run", 0,
          _winreg.KEY_WRITE)
        _winreg.SetValueEx(regkey, "Neubot", 0, _winreg.REG_SZ, cmdline)
        _winreg.CloseKey(regkey)

        # Update the registry to reference the new uninstaller
        regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
          "Software\Microsoft\Windows\CurrentVersion\Uninstall\Neubot", 0,
          _winreg.KEY_WRITE)
        _winreg.SetValueEx(regkey, "DisplayName", 0, _winreg.REG_SZ,
          "Neubot " + utils_version.to_canonical(ctx['vinfo']))
        _winreg.SetValueEx(regkey, "UninstallString", 0, _winreg.REG_SZ,
          uninst)
        _winreg.CloseKey(regkey)

        #
        # Run the new version of Neubot and tell it that this
        # version should be stopped before proceeding with normal
        # startup.
        #
        subprocess.Popen(cmdline_k, close_fds=True)