Beispiel #1
0
def pip_install_from_local_archive(package_args, install_queue=None):
    """
    Wrapper for installing pip package from local Archive
    """
    if get_build_platform() == 'Windows':
        permission_prefix = ''
    elif get_build_platform() == 'Linux':
        permission_prefix = 'gksudo -- '
    elif get_build_platform() == 'Darwin':
        permission_prefix = ''
    package_args = '{}pip3 install {}'.format(permission_prefix, package_args)
    install_process = RunpipSubprocess(package_args, install_queue)
    install_process.start_logging_threads()
Beispiel #2
0
def pip_uninstall(package_args, uninstall_queue=None):
    """
    Uninstall packages
    """

    if get_build_platform() == 'Windows':
        permission_prefix = ''
    elif get_build_platform() == 'Linux':
        permission_prefix = 'gksudo -- '
    elif get_build_platform() == 'Darwin':
        permission_prefix = ''
    package_args = '{}pip3 uninstall --yes {}'.format(permission_prefix,
                                                      package_args)
    uninstall_process = RunpipSubprocess(package_args, uninstall_queue)
    uninstall_process.start_logging_threads()
Beispiel #3
0
    def create_side_navbar(self):
        """
        Create side navigation bar for providing user with options for
        selecting different ways of installation
        """

        # Create a navbar frame in which all navbar buttons will lie
        self.navbar_frame = ttk.Frame(self.container,
                                      borderwidth=3,
                                      padding=0.5,
                                      relief='ridge')
        self.navbar_frame.grid(row=0,
                               column=0,
                               sticky='nsw',
                               pady=(1, 1),
                               padx=(1, 1))
        # Configure style for navbar frame

        # Button text
        pypi_text = "Install From PyPI"
        local_archive_text = "Install From Local Archive"
        requirements_text = "Install From Requirements File"
        pythonlibs_text = "Install From PythonLibs"
        #alternate_repo_text = "Install From Alternate Repository"

        # Button style
        navbar_button_style = ttk.Style()
        navbar_button_style.configure('navbar.TButton', padding=(6, 25))

        self.button_pypi = ttk.Button(
            self.navbar_frame,
            text=pypi_text,
            state='active',
            style='navbar.TButton',
            command=lambda: self.show_frame('InstallFromPyPI'))
        self.button_pypi.grid(row=0, column=0, sticky='nwe')

        self.button_local_archive = ttk.Button(
            self.navbar_frame,
            text=local_archive_text,
            style='navbar.TButton',
            command=lambda: self.show_frame('InstallFromLocalArchive'))
        self.button_local_archive.grid(row=1, column=0, sticky='nwe')

        self.button_requirements = ttk.Button(
            self.navbar_frame,
            text=requirements_text,
            style='navbar.TButton',
            command=lambda: self.show_frame('InstallFromRequirements'))
        self.button_requirements.grid(row=2, column=0, sticky='nwe')

        if get_build_platform() == 'Windows':

            self.button_pythonlibs = ttk.Button(
                self.navbar_frame,
                text=pythonlibs_text,
                style='navbar.TButton',
                command=lambda: self.show_frame('InstallFromPythonlibs'))
            self.button_pythonlibs.grid(row=3, column=0, sticky='nwe')
        '''
Beispiel #4
0
    def manage_frames(self):
        """
        Manage multiple frames. Creates dictionary of multiple frames to
        be used for showing user different GUI frames for different ways of
        installation.
        """

        if get_build_platform() != 'Windows':
            #If not windows
            frames_tuple = (
                InstallFromPyPI,
                InstallFromLocalArchive,
                InstallFromRequirements,
            )

        else:
            #Else add InstallFromPythonlibs page (for Windows systems)
            frames_tuple = (
                InstallFromPyPI,
                InstallFromLocalArchive,
                InstallFromRequirements,
                InstallFromPythonlibs,
            )

        self.frames_dict = {}
        for F in frames_tuple:
            frame_name = F.__name__
            new_frame = F(self.container, self)
            new_frame.grid(row=0, column=1, sticky='nsew')
            self.frames_dict[frame_name] = new_frame

        self.show_frame('InstallFromPyPI')
Beispiel #5
0
    def manage_frames(self):
        """
        Manage multiple frames. Creates dictionary of multiple frames to
        be used for showing user different GUI frames for different ways of
        installation.
        """

        if get_build_platform()!='Windows':
            #If not windows
            frames_tuple = (
                InstallFromPyPI,
                InstallFromLocalArchive,
                InstallFromRequirements,
            )

        else:
            #Else add InstallFromPythonlibs page (for Windows systems)
            frames_tuple = (
                InstallFromPyPI,
                InstallFromLocalArchive,
                InstallFromRequirements,
                InstallFromPythonlibs,
            )

        self.frames_dict = {}
        for F in frames_tuple:
            frame_name = F.__name__
            new_frame = F(self.container, self)
            new_frame.grid(row=0, column=1, sticky='nsew')
            self.frames_dict[frame_name] = new_frame

        self.show_frame('InstallFromPyPI')
Beispiel #6
0
def pip_search_command(package_name=None, thread_queue=None):
    """
    Uses subprocess to retrieve results of 'pip search'
    """
    import re

    #Get search results and errors if there
    search_result, errors = runpip_using_subprocess(
        'pip3 search {}'.format(package_name))

    #If errors, then put error string into queue
    if errors.strip() != '':
        thread_queue.put(errors)

    count = 0
    installed_packages = []

    ######################################################################
    #Parsing shell output
    #Note : Needs to be updated when json output is available for pip
    ######################################################################

    #Sample Output in Windows:
    #
    #django-editos (1.5) - Django app to manage and display editos
    #django-github-webhook (0.1.1) - Django view for GitHub webhook recievers
    #pyserial (3.1.1)      - Python Serial Port Extension
    #INSTALLED: 2.7
    #LATEST:    3.1.1

    #Sample Output in Linux/Unix:
    #
    #django-editos (1.5)    - Django app to manage and display editos
    #django-github-webhook (0.1.1)  - Django view for GitHub webhook recievers
    #pyserial (3.1.1)   - Python Serial Port Extension
    #INSTALLED: 2.7 (LATEST: 3.1.1)

    for x in search_result.split("\n"):
        try:
            #If first line of package decription
            if ('INSTALLED:' not in x) and (('(' in x) and (')' in x) and
                                            (not x.startswith('-'))):
                open_bracket_index = x.index('(')
                close_bracket_index = x.index(')')
                pkg_name = x[:open_bracket_index - 1].strip()
                latest_version = x[open_bracket_index + 1:close_bracket_index]
                summary = re.split(r'\)\s+- ', x)[1].strip()
                installed_packages.append(
                    [pkg_name, 'Not installed', latest_version, summary])
            #Else if package is outdated, also show the outdated version
            elif 'INSTALLED:' in x:
                #If OS is not Windows (Refer to sample output for Linux/Unix)
                if get_build_platform() != 'Windows':
                    st_index = x.index(':')
                    end_index = x.index('(')
                    installed_packages[-1][1] = x[st_index +
                                                  1:end_index].strip()
                #Else if OS is windows ( Refer to Sample Output above)
                else:
                    st_index = x.index(':')
                    installed_packages[-1][1] = x[st_index + 1:].strip()
            #If LINUX/UNIX append package descriptions in subsequent lines
            elif get_build_platform() != 'Windows':
                installed_packages[-1][3] = '{} {}'.format(
                    installed_packages[-1][3], x.strip())
        except:
            pass
    ########################################################################
    ########################################################################
    thread_queue.put([tuple(x) for x in installed_packages])
Beispiel #7
0
    def start_logging_threads(self):
        """
        Starts logging to output and error queue
        """

        # If system platform is not Windows
        if get_build_platform() != 'Windows':

            fileio_streams = [
                self.pip_process.stdout.fileno(),
                self.pip_process.stderr.fileno(),
            ]

            #Do I/O multiplexing
            io_iterator = select.select(fileio_streams, [], [])
            self.output_queue.put((0, 'process_started'))

            while True:

                #iterate over available file descriptors in io_iterator
                for file_descrp in io_iterator[0]:

                    #if something is there in stdout stream
                    if file_descrp == self.pip_process.stdout.fileno():
                        pipout = self.pip_process.stdout.readline()
                        self.output_queue.put((1, pipout))

                    #else check in stderr stream
                    elif file_descrp == self.pip_process.stderr.fileno():
                        piperr = self.pip_process.stderr.readline()
                        self.output_queue.put((2, piperr))

                #Check if process has ended, if process is not completed
                #then self.pip_process.poll() returns None
                if self.pip_process.poll() != None:
                    self.output_queue.put((3, self.pip_process.poll()))
                    break

        #Else if platform is Windows
        else:
            #Create two child threads for this alternate process
            #output thread manages stdout
            output_thread = threading.Thread(target=self.getoutput)
            #error thread manages stderr
            error_thread = threading.Thread(target=self.geterror)

            #send 'process started' indication with message code : 0
            self.output_queue.put((0, 'process_started'))

            #starts both threads
            output_thread.start()
            error_thread.start()

            #Wait for both threads to complete their execution
            output_thread.join()
            error_thread.join()

            #If both threads are completed, then this alternate process should
            #end. If execution completed, then
            if self.pip_process.poll() != None:
                #Send ending message with process code and message code as 3
                self.output_queue.put((3, self.pip_process.poll()))
Beispiel #8
0
    def create_side_navbar(self):
        """
        Create side navigation bar for providing user with options for
        selecting different ways of installation
        """

        # Create a navbar frame in which all navbar buttons will lie
        self.navbar_frame = ttk.Frame(
            self.container,
            borderwidth=3,
            padding=0.5,
            relief='ridge')
        self.navbar_frame.grid(
            row=0,
            column=0,
            sticky='nsw',
            pady=(1,1),
            padx=(1,1))
        # Configure style for navbar frame

        # Button text
        pypi_text = "Install From PyPI"
        local_archive_text = "Install From Local Archive"
        requirements_text = "Install From Requirements File"
        pythonlibs_text = "Install From PythonLibs"
        #alternate_repo_text = "Install From Alternate Repository"

        # Button style
        navbar_button_style = ttk.Style()
        navbar_button_style.configure(
            'navbar.TButton',
            padding=(6, 25)
        )

        self.button_pypi = ttk.Button(
            self.navbar_frame,
            text=pypi_text,
            state='active',
            style='navbar.TButton',
            command=lambda : self.show_frame('InstallFromPyPI')
        )
        self.button_pypi.grid(row=0, column=0, sticky='nwe')

        self.button_local_archive = ttk.Button(
            self.navbar_frame,
            text=local_archive_text,
            style='navbar.TButton',
            command=lambda : self.show_frame('InstallFromLocalArchive')
        )
        self.button_local_archive.grid(row=1, column=0, sticky='nwe')

        self.button_requirements = ttk.Button(
            self.navbar_frame,
            text=requirements_text,
            style='navbar.TButton',
            command=lambda : self.show_frame('InstallFromRequirements')
        )
        self.button_requirements.grid(row=2, column=0, sticky='nwe')

        if get_build_platform()=='Windows':

            self.button_pythonlibs = ttk.Button(
                self.navbar_frame,
                text=pythonlibs_text,
                style='navbar.TButton',
                command=lambda : self.show_frame('InstallFromPythonlibs')
            )
            self.button_pythonlibs.grid(row=3, column=0, sticky='nwe')

        '''