Exemplo n.º 1
0
    def _install_postgres(self):
        self.wizard.disable_back()
        self.wizard.disable_next()
        self.label.set_markup(
            _("Please wait while the package installation is completing."))

        packageinstaller = library.get_resource_filename(
            'stoq', 'scripts', 'packageinstaller.py')
        p = subprocess.Popen(
            [sys.executable, packageinstaller,
             'postgresql', 'postgresql-contrib', 'stoq-server'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()

        self.wizard.enable_back()
        if p.returncode == 0:
            self.done = True
            self.wizard.enable_next()
            self.label.set_markup(
                _("Postgresql installation succeeded. You may now proceed "
                  "to the next step by clicking the <b>Forward</b> button"))
        elif p.returncode == 11:
            self.wizard.enable_next()
            self.label.set_markup(
                _("Authorization failed, try again or connect to "
                  "another database"))
        else:
            warning(_("Something went wrong while trying to install "
                      "the PostgreSQL server."))
            self.label.set_markup(
                _("Sorry, something went wrong while installing PostgreSQL, "
                  "try again manually or go back and configure Stoq to connect "
                  "to another."))
Exemplo n.º 2
0
def show_section(section, screen=None):
    if library.uninstalled:
        root = library.get_root()
        uri = os.path.join(root, 'docs', 'manual', 'pt_BR')
        if section != '':
            uri += '/' + section + '.page'
    else:
        if library.get_resource_exists('stoq', 'docs', 'manual', 'pt_BR'):
            manual_dir = library.get_resource_filename('stoq', 'docs',
                                                       'manual', 'pt_BR')
            if section:
                uri = os.path.join(manual_dir, section + '.page')
            else:
                uri = manual_dir
        else:
            uri = 'stoq'
            if section:
                uri += '?' + section

    if not screen:
        toplevel = get_current_toplevel()
        if toplevel:
            screen = toplevel.get_screen()

    try:
        gtk.show_uri(screen, 'ghelp:' + uri, gtk.get_current_event_time())
    except glib.GError:
        open_browser(
            'http://doc.stoq.com.br/manual/%s/%s.html' % (
                stoq.short_version,
                section or 'index',
            ), screen)
Exemplo n.º 3
0
 def _setup_widgets(self):
     self.image.set_from_file(
         library.get_resource_filename('stoq', 'pixmaps', 'link_step.png'))
     self.image_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                                    gtk.gdk.POINTER_MOTION_MASK)
     self.send_progress.hide()
     self.send_error_label.hide()
Exemplo n.º 4
0
    def _create_dbuser(self, username):
        import os
        from stoqlib.lib.process import Process, PIPE
        for envname in ['PGUSER', 'PGHOST']:
            if envname in os.environ:
                del os.environ[envname]

        # See if we can connect to the database
        args = ['psql', 'postgres', username, '-c', 'SELECT 1;']
        proc = Process(args, stdout=PIPE)
        proc.communicate()
        if proc.returncode == 0:
            return 0

        from stoqlib.lib.kiwilibrary import library

        createdbuser = library.get_resource_filename(
            'stoq', 'scripts', 'createdbuser.sh')

        args = ['pkexec',
                '-u', 'postgres',
                createdbuser,
                username]
        proc = Process(args)
        proc.communicate()

        if proc.returncode != 0:
            print("ERROR: Failed to run %r" % (args, ))
            return 30
        return 0
Exemplo n.º 5
0
    def _create_dbuser(self, username):
        import os
        from stoqlib.lib.process import Process, PIPE
        for envname in ['PGUSER', 'PGHOST']:
            if envname in os.environ:
                del os.environ[envname]

        # See if we can connect to the database
        args = ['psql', 'postgres', username, '-c', 'SELECT 1;']
        proc = Process(args, stdout=PIPE)
        proc.communicate()
        if proc.returncode == 0:
            return 0

        from stoqlib.lib.kiwilibrary import library

        createdbuser = library.get_resource_filename('stoq', 'scripts',
                                                     'createdbuser.sh')

        args = ['pkexec', '-u', 'postgres', createdbuser, username]
        proc = Process(args)
        proc.communicate()

        if proc.returncode != 0:
            print("ERROR: Failed to run %r" % (args, ))
            return 30
        return 0
Exemplo n.º 6
0
def show_section(section, screen=None):
    if library.uninstalled:
        root = library.get_root()
        uri = os.path.join(root, 'docs', 'manual', 'pt_BR')
        if section != '':
            uri += '/' + section + '.page'
    else:
        if library.get_resource_exists('stoq', 'docs', 'manual', 'pt_BR'):
            manual_dir = library.get_resource_filename(
                'stoq', 'docs', 'manual', 'pt_BR')
            if section:
                uri = os.path.join(manual_dir, section + '.page')
            else:
                uri = manual_dir
        else:
            uri = 'stoq'
            if section:
                uri += '?' + section

    if not screen:
        toplevel = get_current_toplevel()
        if toplevel:
            screen = toplevel.get_screen()

    try:
        Gtk.show_uri(screen, 'ghelp:' + uri, Gtk.get_current_event_time())
    except GLib.GError:
        open_browser('http://doc.stoq.com.br/manual/%s/%s.html' % (
            stoq.short_version,
            section or 'index', ), screen)
Exemplo n.º 7
0
 def _setup_widgets(self):
     self.image.set_from_file(
         library.get_resource_filename('stoq', 'pixmaps', 'link_step.png'))
     self.image_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK
                                    | gtk.gdk.POINTER_MOTION_MASK)
     self.send_progress.hide()
     self.send_error_label.hide()
Exemplo n.º 8
0
    def _install_postgres(self):
        self.wizard.disable_back()
        self.wizard.disable_next()
        self.label.set_markup(
            _("Please wait while the package installation is completing."))

        packageinstaller = library.get_resource_filename(
            'stoq', 'scripts', 'packageinstaller.py')
        p = subprocess.Popen(
            [sys.executable, packageinstaller,
             'postgresql', 'postgresql-contrib', 'stoq-server'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()

        self.wizard.enable_back()
        if p.returncode == 0:
            self.done = True
            self.wizard.enable_next()
            self.label.set_markup(
                _("Postgresql installation succeeded. You may now proceed "
                  "to the next step by clicking the <b>Forward</b> button"))
        elif p.returncode == 11:
            self.wizard.enable_next()
            self.label.set_markup(
                _("Authorization failed, try again or connect to "
                  "another database"))
        else:
            warning(_("Something went wrong while trying to install "
                      "the PostgreSQL server."))
            self.label.set_markup(
                _("Sorry, something went wrong while installing PostgreSQL, "
                  "try again manually or go back and configure Stoq to connect "
                  "to another."))
Exemplo n.º 9
0
 def _setup_widgets(self):
     if is_windows:
         # Make it mandatory to register on windows.
         self.register_now.hide()
     self.wizard.disable_cancel()
     self.wizard.disable_back()
     self.image.set_from_file(
         library.get_resource_filename('stoq', 'pixmaps', 'link_step.png'))
     self.image_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                                    | Gdk.EventMask.POINTER_MOTION_MASK)
     self.send_progress.hide()
     self.send_error_label.hide()
Exemplo n.º 10
0
 def _setup_widgets(self):
     if is_windows:
         # Make it mandatory to register on windows.
         self.register_now.hide()
     self.wizard.disable_cancel()
     self.wizard.disable_back()
     self.image.set_from_file(
         library.get_resource_filename('stoq', 'pixmaps', 'link_step.png'))
     self.image_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
                                    Gdk.EventMask.POINTER_MOTION_MASK)
     self.send_progress.hide()
     self.send_error_label.hide()
Exemplo n.º 11
0
    def _read_plugin_descriptions(self):
        # Development plugins on the same checkout
        paths = [os.path.join(library.get_root(), 'plugins')]

        # Plugins on $HOME/.stoq/plugins
        paths.append(os.path.join(get_application_dir(), 'plugins'))

        if library.get_resource_exists('stoq', 'plugins'):
            paths.append(library.get_resource_filename('stoq', 'plugins'))

        paths.extend(list(self._get_external_plugins_paths()))

        for path in paths:
            for filename in glob.iglob(os.path.join(path, '*', '*.plugin')):
                self._register_plugin_description(filename)
            for filename in glob.iglob(os.path.join(path, '*.egg')):
                self._register_plugin_description(filename, is_egg=True)
Exemplo n.º 12
0
    def _read_plugin_descriptions(self):
        # Development plugins on the same checkout
        paths = [os.path.join(library.get_root(), 'plugins')]

        # Plugins on $HOME/.stoq/plugins
        paths.append(os.path.join(get_application_dir(), 'plugins'))

        if library.get_resource_exists('stoq', 'plugins'):
            paths.append(library.get_resource_filename('stoq', 'plugins'))

        paths.extend(list(self._get_external_plugins_paths()))

        for path in paths:
            for filename in glob.iglob(os.path.join(path, '*', '*.plugin')):
                self._register_plugin_description(filename)
            for filename in glob.iglob(os.path.join(path, '*.egg')):
                self._register_plugin_description(filename, is_egg=True)