You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

envdir

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envdir - pypi Package Compare versions

Comparing version
0.3
to
0.4
+5
tox.ini
[tox]
envlist = py26,py27,py33
[testenv]
commands = python setup.py test
+11
-0
Changelog
---------
0.4 (08/09/2013)
^^^^^^^^^^^^^^^^
* Added ``envshell`` command which launches a subshell using the environment
as defined in the given envdir. Example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
0.3 (07/30/2013)

@@ -5,0 +16,0 @@ ^^^^^^^^^^^^^^^^

+1
-0
[console_scripts]
envshell = envdir:main
envdir = envdir:main
Metadata-Version: 1.1
Name: envdir
Version: 0.3
Version: 0.4
Summary: A Python port of daemontools' envdir.

@@ -39,4 +39,4 @@ Home-page: http://github.com/jezdez/envdir

$ tree mysite_env/
mysite_env/
$ tree envs/prod/
envs/prod/
├── DJANGO_SETTINGS_MODULE

@@ -49,3 +49,3 @@ ├── MYSITE_DEBUG

0 directories, 3 files
$ cat mysite_env/DJANGO_SETTINGS_MODULE
$ cat envs/prod/DJANGO_SETTINGS_MODULE
mysite.settings

@@ -58,3 +58,3 @@ $

$ envdir mysite_env python manage.py runserver
$ envdir envs/prod/ python manage.py runserver

@@ -147,4 +147,21 @@ That's it, nothing more and nothing less. The way you structure your envdir

envdir.read('/etc/mysite/envdir')
envdir.read('/home/jezdez/mysite/envs/prod')
Shell
^^^^^
envdir also includes an optional CLI tool called ``envshell`` which launches
a subshell using the given directory. It basically allows you to make a set
of environment variable stick to your current shell session if you happen to
use envdir a lot outside of simple script use.
For example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
To leave the subshell, simply use the ``exit`` command or press ``Ctrl+D``.
Feedback

@@ -160,2 +177,13 @@ --------

0.4 (08/09/2013)
^^^^^^^^^^^^^^^^
* Added ``envshell`` command which launches a subshell using the environment
as defined in the given envdir. Example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
0.3 (07/30/2013)

@@ -162,0 +190,0 @@ ^^^^^^^^^^^^^^^^

@@ -7,2 +7,3 @@ CHANGES.rst

tests.t
tox.ini
envdir/__init__.py

@@ -9,0 +10,0 @@ envdir/__main__.py

+73
-23

@@ -7,5 +7,8 @@ import glob

__version__ = '0.3'
__version__ = '0.4'
# must have shell = True on Windows
shellout = sys.platform == 'win32'
class EnvOptionParser(optparse.OptionParser):

@@ -23,9 +26,8 @@

class Envdir(object):
usage = "usage: %prog [--help] [--version] dir child"
class Runner(object):
envdir_usage = "usage: %prog [--help] [--version] dir child"
envshell_usage = "usage: %prog [--help] [--version] dir"
def __init__(self):
self.parser = EnvOptionParser(self.usage,
version=__version__,
prog='envdir')
self.parser = EnvOptionParser(version=__version__)
self.parser.disable_interspersed_args()

@@ -48,2 +50,9 @@

def path(self, path):
real_path = os.path.realpath(os.path.expanduser(path))
if not os.path.exists(real_path):
# use 111 error code to adher to envdir's standard
self.parser.error("envdir %r does not exist" % path, no=111)
return real_path
def read(self, path=None):

@@ -55,8 +64,3 @@ if path is None:

real_path = os.path.realpath(os.path.expanduser(path))
if not os.path.exists(real_path):
# use 111 error code to adher to envdir's standard
self.parser.error("envdir %r does not exist" % path, no=111)
for name, value in self.environ(real_path):
for name, value in self.environ(self.path(path)):
if value:

@@ -67,5 +71,34 @@ os.environ.setdefault(name, value)

def main(self, args):
options, args = self.parser.parse_args(args)
def shell(self, args):
self.parser.set_usage(self.envshell_usage)
self.parser.prog = 'envshell'
if len(args) == 0:
self.parser.error("incorrect number of arguments")
self.parser.print_usage()
sys.stdout.write("Launching envshell for %s. "
"Type 'exit' or 'Ctrl+D' to return.\n" %
self.path(args[0]))
sys.stdout.flush()
self.read(args[0])
try:
subprocess.check_call([os.environ['SHELL']],
universal_newlines=True,
shell=shellout,
bufsize=0,
close_fds=True)
except OSError as err:
if err.errno == 2:
self.parser.error(err.errno,
"Unable to find shell %s" %
os.environ['SHELL'])
else:
self.parser.exit(err.errno, '')
def call(self, args):
self.parser.set_usage(self.envdir_usage)
self.parser.prog = 'envdir'
if len(args) < 2:

@@ -84,20 +117,37 @@ self.parser.error("incorrect number of arguments")

process = subprocess.Popen(child_args,
universal_newlines=True,
shell=False,
bufsize=0,
close_fds=True)
try:
if process.wait() != 0:
self.parser.exit(process.returncode, '')
subprocess.check_call(child_args,
universal_newlines=True,
shell=shellout,
bufsize=0,
close_fds=True)
except OSError as err:
if err.errno == 2:
self.parser.error(err.errno,
"Unable to find command %s" %
child_args[0])
else:
self.parser.exit(err.errno, '')
except subprocess.CalledProcessError as err:
self.parser.exit(err.returncode, '')
except KeyboardInterrupt:
self.parser.exit()
envdir = Envdir()
def main(self, name, args):
options, args = self.parser.parse_args(args)
if name.endswith('envdir') or name.endswith('__main__.py'):
self.call(args)
elif name.endswith('envshell'):
self.shell(args)
else:
self.parser.print_usage(sys.stderr)
envdir = Runner()
def main():
envdir.main(sys.argv[1:])
envdir.main(sys.argv[0], sys.argv[1:])
if __name__ == '__main__':
main()

@@ -1,2 +0,1 @@

include README.rst CHANGES.rst
include tests.t
include README.rst CHANGES.rst tests.t tox.ini
Metadata-Version: 1.1
Name: envdir
Version: 0.3
Version: 0.4
Summary: A Python port of daemontools' envdir.

@@ -39,4 +39,4 @@ Home-page: http://github.com/jezdez/envdir

$ tree mysite_env/
mysite_env/
$ tree envs/prod/
envs/prod/
├── DJANGO_SETTINGS_MODULE

@@ -49,3 +49,3 @@ ├── MYSITE_DEBUG

0 directories, 3 files
$ cat mysite_env/DJANGO_SETTINGS_MODULE
$ cat envs/prod/DJANGO_SETTINGS_MODULE
mysite.settings

@@ -58,3 +58,3 @@ $

$ envdir mysite_env python manage.py runserver
$ envdir envs/prod/ python manage.py runserver

@@ -147,4 +147,21 @@ That's it, nothing more and nothing less. The way you structure your envdir

envdir.read('/etc/mysite/envdir')
envdir.read('/home/jezdez/mysite/envs/prod')
Shell
^^^^^
envdir also includes an optional CLI tool called ``envshell`` which launches
a subshell using the given directory. It basically allows you to make a set
of environment variable stick to your current shell session if you happen to
use envdir a lot outside of simple script use.
For example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
To leave the subshell, simply use the ``exit`` command or press ``Ctrl+D``.
Feedback

@@ -160,2 +177,13 @@ --------

0.4 (08/09/2013)
^^^^^^^^^^^^^^^^
* Added ``envshell`` command which launches a subshell using the environment
as defined in the given envdir. Example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
0.3 (07/30/2013)

@@ -162,0 +190,0 @@ ^^^^^^^^^^^^^^^^

@@ -31,4 +31,4 @@ envdir (Python port)

$ tree mysite_env/
mysite_env/
$ tree envs/prod/
envs/prod/
├── DJANGO_SETTINGS_MODULE

@@ -41,3 +41,3 @@ ├── MYSITE_DEBUG

0 directories, 3 files
$ cat mysite_env/DJANGO_SETTINGS_MODULE
$ cat envs/prod/DJANGO_SETTINGS_MODULE
mysite.settings

@@ -50,3 +50,3 @@ $

$ envdir mysite_env python manage.py runserver
$ envdir envs/prod/ python manage.py runserver

@@ -139,4 +139,21 @@ That's it, nothing more and nothing less. The way you structure your envdir

envdir.read('/etc/mysite/envdir')
envdir.read('/home/jezdez/mysite/envs/prod')
Shell
^^^^^
envdir also includes an optional CLI tool called ``envshell`` which launches
a subshell using the given directory. It basically allows you to make a set
of environment variable stick to your current shell session if you happen to
use envdir a lot outside of simple script use.
For example::
$ envshell ~/mysite/envs/prod/
Launching envshell for /home/jezdez/mysite/envs/prod. Type 'exit' or 'Ctrl+D' to return.
$ python manage.py runserver
..
To leave the subshell, simply use the ``exit`` command or press ``Ctrl+D``.
Feedback

@@ -143,0 +160,0 @@ --------

@@ -58,5 +58,6 @@ import codecs

packages=['envdir'],
entry_points=dict(console_scripts=['envdir=envdir:main']),
entry_points=dict(console_scripts=['envdir=envdir:main',
'envshell=envdir:main']),
zip_safe=False,
tests_require=['cram'],
cmdclass={'test': CramTest})

Sorry, the diff of this file is not supported yet