Metadata-Version: 1.1
Name: shell_proc
Version: 1.0.1
Summary: Continuous shell process
Home-page: https://github.com/justengel/shell_proc
Author: Justin Engel
Author-email: jtengel08@gmail.com
License: Proprietary
Download-URL: https://github.com/justengel/shell_proc/archive/v1.0.1.tar.gz
Description: ==========
        Shell Proc
        ==========
        
        Install
        =======
        
        .. code-block:: bash
        
            pip install shell_proc
        
        
        Run
        ===
        
        Run a series of terminal commands.
        
        .. code-block:: python
        
            import sys
            from shell_proc import Shell
        
            with Shell(stdout=sys.stdout, stderr=sys.stderr) as sh:
                sh.run('mkdir storage')
                sh('cd storage')  # Same as sh.run()
                sh('python -m venv ./myvenv')
                sh('source ./myvenv/bin/activate')
                sh('pip install requests')
                sh('pip list')
        
        
        Manually call commands and check results.
        
        .. code-block:: python
        
            import io
            import sys
            from shell_proc import Shell
        
            # Initialize and run tasks
            sh = Shell('mkdir storage',
                       'cd storage',
                       'python -m venv ./myvenv',
                       stderr=io.StringIO())
        
            # Manually run tasks
            if sh.is_windows():
                sh.run('call .\\myvenv\\Scripts\\activate.bat')
            else:
                sh.run('source ./myvenv/bin/activate')
        
            # Not exactly success. If True no output was printed to stderr. Stderr could also be warning like need to update pip
            success = sh('pip install requests')
            print("***** Successful install: ", success)
            if not success:
                err = sh.get_stderr()  # All text collected into stderr from subprocess stderr
                print(err, file=sys.stderr)
                # sh.print_stderr()  # Also available
        
            sh.stdout = io.StringIO()  # Start saving output for new tasks
            sh('pip list')
            print('***** Output Printed', sh.has_print_out())
            sh.stdout.seek(0)  # Move to start of io.StringIO()
            print(sh.stdout.read())  # Print all read data
        
            # Should close when finished to stop threads from reading stdout and stderr subprocess.PIPE
            # (will close automatically eventually)
            sh.close()
        
        
        
        
Platform: any
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
