EzDevInfo.com

envoy

Python Subprocesses for Humans™. envoy 0.0.3 : Python Package Index simple api for running external processes.

`envoy`-like abstraction of subprocess [closed]

I was really excited about the Envoy project when I first heard about it. Having a sane API for subprocess is something I very much need.

However, envoy seems not to be maintained anymore. The last commit was made 10 months ago, and the last release was made 2 years ago. There are a bunch of serious bugs in it that I reported a long time ago, but were not fixed.

I'm looking for an alternative. Does anyone know of a Python package that does the same thing as Envoy (gives a good API to subprocess), except it's actively maintained?


Source: (StackOverflow)

Execute bash file from Python

I want to execute a shell script file from within Python. I am currently using Envoy to do this:

envoy.run('./scripts.sh')

But it throws me a No such file or directory error.

I am wondering, under which path is the above file executed? How can I make the above script run? It is located in the same directory as the Python script.


Source: (StackOverflow)

Advertisements

How to use wildcards with Envoy

I'm trying to run this command through KennethReitz's Envoy package:

$ sqlite3 foo.db 'select * from sqlite_master' 

I've tried this:

r = envoy.run("sqlite3 foo.db 'select * from sqlite_master'")
sqlite3: Error: too many options: "*"

and this:

r = envoy.run(['sqlite3', 'foo.db', 'select * from sqlite_master'])
AttributeError: 'NoneType' object has no attribute 'returncode'

additional quoting & escaping doesn't seem to help. Any suggestions?

FYI: This is what I had to do for now:

cmd = "sqlite3 %(database)s 'select * from sqlite_master'" % locals()
os.system(cmd)

Note that this is a contrived example, and that most of the unix shell commands that I'd like to issue aren't just a simple select that could be easily done via SQLAlchemy.


Source: (StackOverflow)

how to use envoy package in python?

I have installed package envoy. I ran the script but a windows error occured .I commented envoy.run then the full script runs but when I remove the comment, error occurs.

 import envoy

 # This data is checked-in to the repository and is a compressed 
 # version of the output from Example 3

 F = 'resources/ch06-mailboxes/data/enron.mbox.json.bz2'

 r = envoy.run("bunzip2 %s" % (F,))
 print r.std_out
 print r.std_err

traceback of script:

 Exception in thread Thread-9:
Traceback (most recent call last):
 File "C:\Users\sachin\Anaconda\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Users\sachin\Anaconda\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\sachin\Anaconda\lib\site-packages\envoy\core.py", line 40, in target
bufsize=0,
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Source: (StackOverflow)

How to avoid zombie process with envoy.connect?

I just discovered the 'envoy' module, a wrapper for python subprocess made by the creator of requests.

I have a problem with the 'connect' function: everytime I use it, it results in a zombie process and I can't get the status_code or the result.

c=envoy.connect("ls -al")
c.status_code == None
 True

If I do a 'ps -ef|grep thepid', I get a 'defunct' pid.

I can kill the zombie by doing a os.wait() or a c._process.wait(), but I can't get the result (stdout) of my command...

Any idea?


Source: (StackOverflow)

Using rm * (wildcard) in envoy: No such file or directory

I'm using Python and Envoy. I need to delete all files in a directory. Apart from some files, the directory is empty. In a terminal this would be:

rm /tmp/my_silly_directory/*

Common sense dictates that in envoy, this translates into:

r = envoy.run('rm /tmp/my_silly_directory/*')

However:

r.std_err -> "rm: cannot remove `/tmp/my_silly_directory/*': No such file or directory"

Naturally there are alternatives to using envoy in this case, I am simply wondering why it doesn't work.

Any clues?


Source: (StackOverflow)