Skip to content

Commit

Permalink
Fix exit codes and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ggatward committed Apr 11, 2017
1 parent d57ab03 commit e0aa645
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 46 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion check_sync.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_running_tasks(clear):

# Exit the loop if both tests are clear
if not running_sync and not incomplete_sync:
sys.exit(-1)
sys.exit(0)


def main(args):
Expand Down Expand Up @@ -121,6 +121,8 @@ def main(args):
clear = False
check_running_tasks(clear)

sys.exit(0)

if __name__ == "__main__":
try:
main(sys.argv[1:])
Expand Down
8 changes: 5 additions & 3 deletions clean_content_views.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall):
if not ver_list:
msg = "No content view versions found matching cleanup criteria"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)

for cvid in ver_list.keys():
# Check if there is a publish/promote already running on this content view
Expand Down Expand Up @@ -179,7 +179,7 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall):
if dry_run:
msg = "Dry run - not actually performing removal"
helpers.log_msg(msg, 'WARNING')
sys.exit(-1)
sys.exit(2)


def main(args):
Expand Down Expand Up @@ -231,7 +231,7 @@ def main(args):
if not cleanup_list:
msg = "Cannot find cleanup configuration"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)

msg = "Config found for CV's " + str(cleanup_list)
helpers.log_msg(msg, 'DEBUG')
Expand All @@ -245,6 +245,8 @@ def main(args):
# Clean the content views. Returns a list of task IDs.
cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall)

# Exit cleanly
sys.exit(0)

if __name__ == "__main__":
try:
Expand Down
2 changes: 1 addition & 1 deletion config/config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ promotion:
- RHEL Server
- RHEL Workstation

lifecyclec2:
lifecycle2:
name: Desktop QA
content_views:
- RHEL Workstation
Expand Down
Empty file modified download_manifest.py
100755 → 100644
Empty file.
10 changes: 5 additions & 5 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import requests
except ImportError:
print "Please install the python-requests module."
sys.exit(-1)
sys.exit(1)

try:
import yaml
except ImportError:
print "Please install the PyYAML module."
sys.exit(-1)
sys.exit(1)


# Import the site-specific configs
Expand Down Expand Up @@ -175,7 +175,7 @@ def get_org_id(org_name):
if org.get('error', None):
msg = "Organization '%s' does not exist." % org_name
log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)
else:
# Our organization exists, so let's grab the ID and write some debug
org_id = org['id']
Expand Down Expand Up @@ -337,12 +337,12 @@ def check_running_sync():
if task_result['humanized']['action'] == 'Synchronize':
msg = "Unable to start sync - a Sync task is currently running"
log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)
if task_result['state'] == 'paused' and task_result['label'] != 'Actions::BulkAction':
if task_result['humanized']['action'] == 'Synchronize':
msg = "Unable to start sync - a Sync task is paused. Resume any paused sync tasks."
log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)


def check_running_publish(cvid, desc):
Expand Down
2 changes: 1 addition & 1 deletion man/sat_export.8
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The Default Org View (DoV) will be exported unless a specific environment is spe
.BR "-s", " --since"
.I "DATE"
.RS 3
Perform an incrementatl export of content synchronised since
Perform an incremental export of content synchronised since
.IR date ,
specified as "YYYY-MM-DD HH:MM:SS"
.RE
Expand Down
14 changes: 8 additions & 6 deletions promote_content_views.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import yaml
except ImportError:
print "Please install the PyYAML module."
sys.exit(-1)
sys.exit(1)


# Get the details about the environments
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_cv(org_id, target_env, env_list, prior_list, promote_list):
if not target_env in env_list:
msg = "Target environment '" + target_env + "' not found"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)
else:
target_env_id = env_list[target_env]
source_env_id = prior_list[target_env_id]
Expand Down Expand Up @@ -131,7 +131,7 @@ def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list,
if not ver_list:
msg = "No content view versions found matching promotion criteria"
helpers.log_msg(msg, 'WARNING')
sys.exit(-1)
sys.exit(1)

for cvid in ver_list.keys():

Expand Down Expand Up @@ -164,7 +164,7 @@ def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list,
if dry_run:
msg = "Dry run - not actually performing promotion"
helpers.log_msg(msg, 'WARNING')
sys.exit(-1)
sys.exit(2)


return task_list, ref_list, task_name
Expand Down Expand Up @@ -231,7 +231,7 @@ def main(args):
print lenv, time
else:
print 'No promotions recorded'
sys.exit(-1)
sys.exit(0)

# Error if no environment to promote to is given
if args.env is None:
Expand All @@ -246,7 +246,7 @@ def main(args):
if not promote_list:
msg = "Cannot find promotion configuration for '" + target_env + "'"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)

msg = "Config found for CV's " + str(promote_list)
helpers.log_msg(msg, 'DEBUG')
Expand All @@ -272,6 +272,8 @@ def main(args):
# Monitor the status of the promotion tasks
helpers.watch_tasks(task_list, ref_list, task_name)

# Exit cleanly
sys.exit(0)

if __name__ == "__main__":
try:
Expand Down
10 changes: 6 additions & 4 deletions publish_content_views.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def publish(ver_list, ver_descr, ver_version, dry_run, runuser):
if not ver_list:
msg = "No content view versions found matching publication criteria"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)

for cvid in ver_list.keys():

Expand Down Expand Up @@ -102,7 +102,7 @@ def publish(ver_list, ver_descr, ver_version, dry_run, runuser):
if dry_run:
msg = "Dry run - not actually performing publish"
helpers.log_msg(msg, 'WARNING')
sys.exit(-1)
sys.exit(2)


return task_list, ref_list, task_name
Expand Down Expand Up @@ -167,7 +167,7 @@ def main(args):
print lenv, time
else:
print 'No promotions recorded'
sys.exit(-1)
sys.exit(0)


publish_list = []
Expand All @@ -177,7 +177,7 @@ def main(args):
if not publish_list:
msg = "Cannot find publish configuration"
helpers.log_msg(msg, 'ERROR')
sys.exit(-1)
sys.exit(1)

msg = "Config found for CV's " + str(publish_list)
helpers.log_msg(msg, 'DEBUG')
Expand All @@ -198,6 +198,8 @@ def main(args):
# Monitor the status of the publish tasks
helpers.watch_tasks(task_list, ref_list, task_name)

# Exit cleanly
sys.exit(0)

if __name__ == "__main__":
try:
Expand Down
8 changes: 4 additions & 4 deletions push_puppetforge.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import yaml
except ImportError:
print "Please install the PyYAML module."
sys.exit(-1)
sys.exit(1)


def export_puppet(repo_id, repo_label, repo_relative, export_type):
Expand Down Expand Up @@ -140,7 +140,7 @@ def main(args):
else:
if not helpers.PFSERVER:
print "Puppet forge server not defined"
sys.exit(-1)
sys.exit(1)
else:
pfserver = helpers.PFSERVER

Expand All @@ -167,7 +167,7 @@ def main(args):
pfrepo = args.repo
else:
print "Puppetforge repo not defined"
sys.exit(-1)
sys.exit(1)

# Remove any previous exported content left behind by prior unclean exit
if os.path.exists(helpers.EXPORTDIR + '/export'):
Expand Down Expand Up @@ -213,7 +213,7 @@ def main(args):

# And we're done!
print helpers.GREEN + "Puppet Forge export complete.\n" + helpers.ENDC

sys.exit(0)

if __name__ == "__main__":
try:
Expand Down
Loading

0 comments on commit e0aa645

Please sign in to comment.