Пример #1
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)
Пример #2
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)
Пример #3
0
import cgi
import os

from neubot.compat import json
from neubot.config import CONFIG
from neubot.http.message import Message
from neubot.utils_api import NotImplementedTest

from neubot import utils_hier
from neubot import utils_path
from neubot import utils

# Directory that contains the description of each test, which consists of
# two files per test: a JSON file and an HTML file.
TESTDIR = utils_path.join(utils_hier.WWWDIR, 'test')

# Config variables to be copied to output: they allow ordinary users to
# configure the appearance of results.html.
COPY_CONFIG_VARIABLES = (
    'www_no_description',
    'www_no_legend',
    'www_no_plot',
    'www_no_split_by_ip',
    'www_no_table',
    'www_no_title',
)

def api_results(stream, request, query):
    ''' Populates www/results.html page '''
Пример #4
0
 def test_with_pathsep(self):
     ''' Just make sure join() works w/ pathseps '''
     expected = os.sep.join(['ab/c', 'd/../ef'])
     self.assertEqual(utils_path.join('ab/c', 'd/../ef'), expected)
Пример #5
0
 def test_simple(self):
     ''' Just make sure join() works in the simple case '''
     expected = os.sep.join(['abc', 'def'])
     self.assertEqual(utils_path.join('abc', 'def'), expected)