Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from krux/pk-W-6900898-python3
Browse files Browse the repository at this point in the history
update to python3
  • Loading branch information
paul-krohn authored Dec 17, 2019
2 parents 8a2fee2 + ff0ce6c commit 259a163
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 215 deletions.
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ verify_ssl = true
name = "pypi"

[packages]
krux-stdlib = "==3.1.0"
marathon = "==0.11.0"
krux-stdlib = "==4.0.1"
marathon = "==0.12.0"

[requires]
python_version = "2.7"
python_version = "3.6"
180 changes: 16 additions & 164 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion krux_marathon_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.1.0'
VERSION = '0.2.0'
31 changes: 12 additions & 19 deletions krux_marathon_api/cli.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
#!/usr/bin/env python

#
# Standard libraries
#

from __future__ import absolute_import
import json
import os
import re
import sys

#
# Third party libraries
#

from marathon import MarathonClient
from marathon.util import MarathonJsonEncoder
from marathon.client import MarathonHttpError

#
# Internal libraries
#

from krux.cli import Application, get_group
import krux_marathon_api.marathonapi
Expand All @@ -38,8 +31,8 @@ def __init__(self):
self.marathon_list_apps = self.args.list_apps
self.json = self.args.json
if self.args.config_file:
### Handles files passed via i.e. ~/some-link.json and it will translate
### to the proper full location
# Handles files passed via i.e. ~/some-link.json and it will translate
# to the proper full location
self.marathon_config_file = os.path.realpath(
os.path.expanduser(self.args.config_file)
)
Expand Down Expand Up @@ -113,8 +106,8 @@ def run_app(self):
json config file or using the App name from the command line.
"""

### if not a single modifier is specified, show the usage string instead
### of segfaulting
# if not a single modifier is specified, show the usage string instead
# of segfaulting
if not any([
self.args.list_apps,
self.args.config_file,
Expand All @@ -131,14 +124,14 @@ def run_app(self):
password=self.marathon_pass,
)

### validate socket connection with given host and port
# validate socket connection with given host and port
if self.api.connect(self.marathon_host, int(self.marathon_port)):
self.logger.info('Connection success')
else:
self.logger.error('Error connecting to Server')
raise IOError('Error connecting to Server')

### list all apps if flag is called
# list all apps if flag is called
if self.marathon_list_apps:
apps = self.api.get_marathon_apps(marathon_server)
if self.json:
Expand All @@ -157,7 +150,7 @@ def run_app(self):
for app in apps:
print('{0} => {1}'.format(app.id, app.cmd))

### Config file load, only if we passed the variable
# Config file load, only if we passed the variable
if self.marathon_config_file and not self.args.delete:
config_file_data = self.api.read_config_file(self.marathon_config_file)

Expand All @@ -172,15 +165,15 @@ def run_app(self):
raise ValueError('Input config file appears to be in the wrong format')

for app in apps:
### get a specific marathon app
# get a specific marathon app
marathon_app_result = self.api.get_marathon_app(marathon_server, app, app["id"])
self.logger.info('marathon app before updates: ')
self.logger.info(marathon_app_result)

### update local app data variable with config file values
# update local app data variable with config file values
changes_in_json, new_marathon_app = self.api.assign_config_data(app, marathon_app_result)

### update a marathon app if there was a change in the json file
# update a marathon app if there was a change in the json file
if changes_in_json:
self.logger.info('marathon app after updates: ')
self.api.update_marathon_app(marathon_server, app, new_marathon_app)
Expand All @@ -191,9 +184,9 @@ def run_app(self):
marathon_app_result = self.api.get_marathon_app(marathon_server, config_file_data, self.args.get_app)
self.logger.info(marathon_app_result)

### Delete marathon app
# Delete marathon app
if self.args.delete:
### check if the named app exists
# check if the named app exists
try:
marathon_app_result = marathon_server.get_app(self.args.delete)
self.logger.info('Deleting %s', self.args.delete)
Expand Down
Loading

0 comments on commit 259a163

Please sign in to comment.