Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Merge d7367f9 into be0df58
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigouze committed Sep 14, 2018
2 parents be0df58 + d7367f9 commit b165d8d
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 126 deletions.
4 changes: 2 additions & 2 deletions gandi/cli/commands/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
except NameError:
basestring = (str, bytes)

type_list = list

from gandi.cli.core.cli import cli
from gandi.cli.core.utils import output_cert, output_cert_oper, display_rows
from gandi.cli.core.params import (pass_gandi, IntChoice,
Expand All @@ -20,6 +18,8 @@
CERTIFICATE_PACKAGE_MAX,
CERTIFICATE_PACKAGE_WARRANTY)

type_list = list


@cli.group(name='certificate')
@pass_gandi
Expand Down
4 changes: 2 additions & 2 deletions gandi/cli/commands/certstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
except NameError:
basestring = (str, bytes)

type_list = list

from gandi.cli.core.cli import cli
from gandi.cli.core.utils import output_hostedcert
from gandi.cli.core.params import pass_gandi

type_list = list


@cli.group(name='certstore')
@pass_gandi
Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/commands/webacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def info(gandi, resource, format):
iface = gandi.iface.info(ip['iface_id'])
server['name'] = gandi.iaas.info(iface['vm_id'])['hostname']
output_servers = ['name', 'ip', 'port', 'state']
except:
except Exception:
warningmsg = ('\tBackend with ip address %s no longer exists.'
'\n\tYou should remove it.' % server['ip'])
gandi.echo(warningmsg)
Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

try:
use_man_epilog = platform.system() == 'Linux'
except:
except Exception:
pass


Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def request(cls, method, url, **kwargs):
if isinstance(err, requests.HTTPError):
try:
resp = response.json()
except:
except Exception:
msg = 'An unknown error has occurred: %s' % err
raise APICallFailed(msg)

Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def output_json(gandi, format, value):
gandi.echo(json.dumps(value, default=date_handler, sort_keys=True))
elif format == 'pretty-json':
gandi.echo(json.dumps(value, default=date_handler, sort_keys=True,
indent=2, separators=(',', ': ')))
indent=2, separators=(',', ': ')))


def output_sub_line(gandi, key, val, justify):
Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/modules/cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_latest_valid(cls, hosts):
if len(set(hosts) - cert_hosts) == 0:
if (possible and possible['date_end'] < cert['date_end']
or not possible):
possible = cert
possible = cert

return possible

Expand Down
4 changes: 2 additions & 2 deletions gandi/cli/modules/iaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def scp(cls, vm_id, login, identity, local_file, remote_file):
ip_addr = '[%s]' % ip_addr

cmd.extend((local_file, '%s@%s:%s' %
(login, ip_addr, remote_file),))
(login, ip_addr, remote_file),))
cls.echo('Running %s' % ' '.join(cmd))
for _ in range(5):
ret = cls.execute(cmd, False)
Expand Down Expand Up @@ -569,7 +569,7 @@ def from_label(cls, label, datacenter=None):
"""Retrieve disk image id associated to a label."""
result = cls.list(datacenter=datacenter)
image_labels = dict([(image['label'], image['disk_id'])
for image in result])
for image in result])

return image_labels.get(label)

Expand Down
107 changes: 54 additions & 53 deletions gandi/cli/tests/commands/test_certstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_list(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
----------
subject : /OU=Domain Control Validated/OU=Gandi Standard Wildcard SSL/CN=*.domain.fr
""")
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_list_all(self):
Expand All @@ -37,80 +37,81 @@ def test_list_all(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
date_created: 20150407T00:00:00
date_expire : 20160316T00:00:00
----------
fqdn : test1.domain.fr
----------
vhost : test1.domain.fr
type : paas
\t----------
\tfqdn : test1.domain.fr
\t----------
\tvhost : test1.domain.fr
\ttype : paas
----------
id : 2
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
date_created: 20150407T00:00:00
date_expire : 20160316T00:00:00
----------
fqdn : test1.domain.fr
----------
vhost : test1.domain.fr
type : paas
\t----------
\tfqdn : test1.domain.fr
\t----------
\tvhost : test1.domain.fr
\ttype : paas
----------
id : 3
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test2.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test2.domain.fr
\t----------
\tfqdn : test2.domain.fr
----------
id : 4
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test3.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test3.domain.fr
\t----------
\tfqdn : test3.domain.fr
----------
id : 5
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test4.domain.fr
\t----------
\tfqdn : test4.domain.fr
----------
id : 6
subject : /OU=Domain Control Validated/OU=Gandi Standard Wildcard SSL/CN=*.domain.fr
date_created: 20150409T00:00:00
date_expire : 20160409T00:00:00
----------
fqdn : *.domain.fr
----------
vhost : *.domain.fr
type : paas
""")
\t----------
\tfqdn : *.domain.fr
\t----------
\tvhost : *.domain.fr
\ttype : paas
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_info_fqdn(self):

result = self.invoke_with_exceptions(certstore.info, ['test1.domain.fr'])
result = self.invoke_with_exceptions(
certstore.info, ['test1.domain.fr'])

self.assertEqual(result.output, """\
id : 1
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
date_created: 20150407T00:00:00
date_expire : 20160316T00:00:00
----------
fqdn : test1.domain.fr
----------
vhost : test1.domain.fr
type : paas
\t----------
\tfqdn : test1.domain.fr
\t----------
\tvhost : test1.domain.fr
\ttype : paas
----------
id : 2
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
date_created: 20150407T00:00:00
date_expire : 20160316T00:00:00
----------
fqdn : test1.domain.fr
----------
vhost : test1.domain.fr
type : paas
""")
\t----------
\tfqdn : test1.domain.fr
\t----------
\tvhost : test1.domain.fr
\ttype : paas
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_info_id(self):
Expand All @@ -121,12 +122,12 @@ def test_info_id(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
date_created: 20150407T00:00:00
date_expire : 20160316T00:00:00
----------
fqdn : test1.domain.fr
----------
vhost : test1.domain.fr
type : paas
""")
\t----------
\tfqdn : test1.domain.fr
\t----------
\tvhost : test1.domain.fr
\ttype : paas
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_create(self):
Expand All @@ -138,9 +139,9 @@ def test_create(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test4.domain.fr
""")
\t----------
\tfqdn : test4.domain.fr
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_create_id(self):
Expand All @@ -152,9 +153,9 @@ def test_create_id(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test4.domain.fr
""")
\t----------
\tfqdn : test4.domain.fr
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_create_missing(self):
Expand All @@ -176,9 +177,9 @@ def test_create_too_many(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test4.domain.fr
""")
\t----------
\tfqdn : test4.domain.fr
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_create_parameter_files(self):
Expand All @@ -198,9 +199,9 @@ def test_create_parameter_files(self):
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
date_created: 20150408T00:00:00
date_expire : 20160408T00:00:00
----------
fqdn : test4.domain.fr
""")
\t----------
\tfqdn : test4.domain.fr
""") # noqa
self.assertEqual(result.exit_code, 0)

def test_delete(self):
Expand Down
2 changes: 1 addition & 1 deletion gandi/cli/tests/commands/test_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ def test_create_apikey_ok(self):
self.assertTrue('api' in GandiModule._conffiles['global'])

api_key = GandiModule._conffiles['global']['api'].get('key')
self.assertEqual(api_key,'apikey0002')
self.assertEqual(api_key, 'apikey0002')

0 comments on commit b165d8d

Please sign in to comment.