Skip to content

Commit

Permalink
Merge pull request #13 from voltgrid/feature/add-debug
Browse files Browse the repository at this point in the history
Feature/add debug
  • Loading branch information
macropin authored Aug 24, 2018
2 parents 88bf5fe + 9091d61 commit 9db3713
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- 2.7
- 3.3
- 3.4
- 3.6

install:
- pip install -r requirements.txt
Expand Down
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014-2017, Volt Grid Pty Ltd
Copyright (c) 2014-2018, Volt Grid Pty Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -25,4 +25,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Configuration

### Environment

- `VOLTGRID_PIE_DEBUG` set to `true` to enable environment variable debugging.

### voltgrid.conf

An example is provided [here](examples/voltgrid.conf.example).
Expand Down
14 changes: 12 additions & 2 deletions voltgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from distutils.dir_util import copy_tree


__version__ = '1.0.6'
__version__ = '1.0.7'

# Config
VG_CONF_PATH = '/usr/local/etc/voltgrid.conf'
Expand All @@ -31,7 +31,6 @@ class ConfigManager(object):
config = {}
environment = os.environ


def __init__(self, cfg_file=None):
# Assume same dir as voltgrid.py if not specified
cfg_file = cfg_file or os.path.join(os.path.abspath(os.path.split(__file__)[0]), 'voltgrid.conf')
Expand Down Expand Up @@ -308,6 +307,15 @@ def execute(arg, user, group):
sys.stdout.flush()
os.execvpe(arg[1], arg[1:], os.environ) # replace current process, inherit environment

def vg_debug():
debug = bool(os.environ.get('VOLTGRID_PIE_DEBUG', 'False').lower() in ("true", "yes", "t", "1"))
print("voltgrid.py debug %s" % str(debug))
if debug:
for env in os.environ:
val = os.getenv(env)
print("Environment: %s='%s'" % (env, val))
return debug

# Unset inherited environment variables that dont need to be configured
for e in ['HOME',]:
print("Unsetting %s" % e)
Expand All @@ -323,6 +331,8 @@ def execute(arg, user, group):
files = local_config.get('files', {})
dirs = local_config.get('dirs', {})

VOLTGRID_PIE_DEBUG = vg_debug()

# Checkout Git
if c.git_url is not None:
g = GitManager(url=c.git_url, git_dst=c.git_dst, git_branch=c.git_branch, git_tag=c.git_tag, git_hash=c.git_hash)
Expand Down

0 comments on commit 9db3713

Please sign in to comment.