Skip to content

Commit

Permalink
Merge pull request #29 from jazz-jack/master
Browse files Browse the repository at this point in the history
Fixes for bytes operator in 2.7 and dots. ipython requirement is now optional
  • Loading branch information
ToxicWar authored Nov 28, 2017
2 parents d4f754d + 52dd9a9 commit ff056de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions apsconnectcli/apsconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ def _get_cfg():
return cfg


def _to_bytes(raw_str):
if sys.version_info >= (3,):
return bytes(raw_str, 'utf-8')
else:
return bytearray(raw_str, 'utf-8')


def _cluster_probe_connection(api, api_client):
try:
api.get_code()
Expand All @@ -696,7 +703,7 @@ def _create_secret(name, data_format, data, api, namespace='default', force=Fals
secret = {
'apiVersion': 'v1',
'data': {
'config': base64.b64encode(bytes(config, 'utf-8')).decode(),
'config': base64.b64encode(_to_bytes(config)).decode(),
},
'kind': 'Secret',
'metadata': {
Expand Down Expand Up @@ -976,8 +983,7 @@ def _check_connector_backend_access(url, timeout=120):
print()
return

sys.stdout.write('.')
sys.stdout.flush()
raise_by_max_time("Waiting time exceeded", max_time)
except SSLError:
raise_by_max_time("An SSL error occurred", max_time)
except Timeout:
Expand All @@ -987,15 +993,16 @@ def _check_connector_backend_access(url, timeout=120):
except Exception as e:
raise_by_max_time(str(e), max_time)

raise_by_max_time("Waiting time exceeded", max_time)

time.sleep(10)


def raise_by_max_time(msg, max_time):
if datetime.now() >= max_time:
raise Exception(msg)

sys.stdout.write('.')
sys.stdout.flush()


def _get_resources(tenant_schema_path, type='Counter', _filter=None):
resource_type = 'http://aps-standard.org/types/core/resource/1.0#{}'.format(type)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fire==0.1.0
fire==0.1.2
future==0.16.0
osaapi==0.3.12
requests==2.13.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
setup(
name='apsconnectcli',
author='Ingram Micro',
version='1.7.14',
version='1.7.15',
keywords='aps apsconnect connector automation',
extras_require={
':python_version<="2.7"': ['backports.tempfile==1.0rc1']},
Expand Down

0 comments on commit ff056de

Please sign in to comment.