Skip to content

Commit ba5119b

Browse files
committed
Refs #6, flake8 code cleanup nearly done.
1 parent 3b9d90a commit ba5119b

8 files changed

Lines changed: 72 additions & 37 deletions

File tree

api/tests/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def send_patch(self, path, data='', content_type='application/octet-stream',
2727
RequestFactory.patch = construct_patch
2828
Client.patch = send_patch
2929

30-
from .auth import *
31-
from .backend import *
32-
from .build import *
33-
from .config import *
34-
from .container import *
35-
from .flavor import *
36-
from .formation import *
37-
from .node import *
38-
from .provider import *
39-
from .proxy import *
40-
from .release import *
30+
from .auth import * # noqa
31+
from .backend import * # noqa
32+
from .build import * # noqa
33+
from .config import * # noqa
34+
from .container import * # noqa
35+
from .flavor import * # noqa
36+
from .formation import * # noqa
37+
from .node import * # noqa
38+
from .provider import * # noqa
39+
from .proxy import * # noqa
40+
from .release import * # noqa

api/tests/formation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def test_formation(self):
5858

5959
def test_formation_auto_id(self):
6060
body = {'flavor': 'autotest', 'image': 'deis/autotest'}
61-
response = self.client.post('/api/formations', json.dumps(body), content_type='application/json')
61+
response = self.client.post(
62+
'/api/formations', json.dumps(body), content_type='application/json')
6263
self.assertEqual(response.status_code, 201)
6364
self.assertTrue(response.data['id'])
6465
return response
@@ -79,11 +80,13 @@ def test_formation_ssh_override(self):
7980
def test_formation_errors(self):
8081
# test duplicate id
8182
body = {'flavor': 'autotest', 'image': 'deis/autotest'}
82-
response = self.client.post('/api/formations', json.dumps(body), content_type='application/json')
83+
response = self.client.post(
84+
'/api/formations', json.dumps(body), content_type='application/json')
8385
self.assertEqual(response.status_code, 201)
8486
self.assertTrue(response.data['id'])
8587
body = {'id': response.data['id'], 'flavor': 'autotest', 'image': 'deis/autotest'}
86-
response = self.client.post('/api/formations', json.dumps(body), content_type='application/json')
88+
response = self.client.post(
89+
'/api/formations', json.dumps(body), content_type='application/json')
8790
self.assertEqual(response.status_code, 400)
8891
self.assertEqual(json.loads(response.content), 'Formation with this Id already exists.')
8992

api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def post_save(self, formation, created=False, **kwargs):
179179
owner=formation.owner, formation=formation, values={})
180180
build = models.Build.objects.create(
181181
owner=formation.owner, formation=formation)
182-
_release = models.Release.objects.create(
182+
models.Release.objects.create(
183183
owner=formation.owner, formation=formation, config=config,
184184
image=formation.image, build=build)
185185
# prepare the formation's required infrastruture at the provider

celerytasks/azuresms.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,30 @@
1212
@task(name='azuresms.launch_node')
1313
def launch_node(node_id, creds, params, init, ssh_username, ssh_private_key):
1414
# install this manually in your virtual env https://github.com/WindowsAzure/azure-sdk-for-python
15-
# http://scottdensmore.typepad.com/blog/2012/01/creating-a-ssl-certificate-for-the-cloud-ready-packages-for-the-ios-windows-azure-toolkit.html
15+
# "pip install azure"
16+
# http://scottdensmore.typepad.com/blog/2012/01/
17+
# creating-a-ssl-certificate-for-the-cloud-ready-packages-for-the-ios-windows-azure-toolkit.html
1618
# I got all these weird "random" errors that didnt effect anything
17-
sms = ServiceManagementService(subscription_id="69581868-8a08-4d98-a5b0-1d111c616fc3", cert_file="/Users/dgriffin/certs/iOSWAToolkit.pem")
19+
sms = ServiceManagementService(
20+
subscription_id='69581868-8a08-4d98-a5b0-1d111c616fc3',
21+
cert_file='/Users/dgriffin/certs/iOSWAToolkit.pem')
1822
for i in sms.list_os_images():
19-
print "I is ", i.name, " -- ", i.label, " -- ", i.location, " -- ", i.media_link
20-
media_link = "http://opdemandstorage.blob.core.windows.net/communityimages/b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB.vhd"
23+
print 'I is ', i.name, ' -- ', i.label, ' -- ', i.location, ' -- ', i.media_link
24+
media_link = \
25+
'http://opdemandstorage.blob.core.windows.net/communityimages/' + \
26+
'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-' + \
27+
'precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB.vhd'
2128
config = LinuxConfigurationSet(user_name="ubuntu", user_password="opdemand")
22-
hard_disk = OSVirtualHardDisk('b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB', media_link, disk_label='opdemandservice')
23-
ret = sms.create_virtual_machine_deployment('opdemandservice', 'deploy1', "production", "opdemandservice2", "opdemandservice3", config, hard_disk)
24-
#service_name, deployment_name, deployment_slot, label, role_name, system_config, os_virtual_hard_disk
25-
print "Ret ", ret
29+
hard_disk = OSVirtualHardDisk(
30+
'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-' +
31+
'precise-12_04_2-LTS-amd64-server-20130702-en-us-30GB',
32+
media_link, disk_label='opdemandservice')
33+
ret = sms.create_virtual_machine_deployment(
34+
'opdemandservice', 'deploy1', 'production', 'opdemandservice2',
35+
'opdemandservice3', config, hard_disk)
36+
# service_name, deployment_name, deployment_slot, label, role_name
37+
# system_config, os_virtual_hard_disk
38+
print 'Ret ', ret
2639
return sms
2740

2841

@@ -49,7 +62,7 @@ def prepare_run_kwargs(params, init):
4962
'kernel_id': None, 'ramdisk_id': None,
5063
'monitoring_enabled': False, 'subnet_id': None,
5164
'block_device_map': None,
52-
}
65+
}
5366
# convert zone "any" to NoneType
5467
requested_zone = params.get('zone')
5568
if requested_zone and requested_zone.lower() == 'any':
@@ -61,7 +74,7 @@ def prepare_run_kwargs(params, init):
6174
'security_groups': params['security_groups'],
6275
'placement': requested_zone,
6376
'kernel_id': params.get('kernel', None),
64-
}
77+
}
6578
# update user_data
6679
cloud_config = '#cloud-config\n'+yaml.safe_dump(init)
6780
kwargs.update({'user_data': cloud_config})
@@ -74,8 +87,7 @@ def format_metadata(boto):
7487
return {
7588
'architecture': boto.architecture,
7689
'block_device_mapping': {
77-
k: v.volume_id for k, v in boto.block_device_mapping.items()
78-
},
90+
k: v.volume_id for k, v in boto.block_device_mapping.items()},
7991
'client_token': boto.client_token,
8092
'dns_name': boto.dns_name,
8193
'ebs_optimized': boto.ebs_optimized,
@@ -118,5 +130,5 @@ def format_metadata(boto):
118130

119131

120132
if __name__ == "__main__":
121-
print "Checking "
133+
print 'Checking '
122134
l = launch_node(None, None, None, None, None, None)

celerytasks/chef_rsa.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
This file as copied from pyChef at https://github.com/coderanger/pychef
33
"""
44

5+
from ctypes import CDLL
6+
from ctypes import byref
7+
from ctypes import c_char_p
8+
from ctypes import c_int
9+
from ctypes import c_long
10+
from ctypes import c_size_t
11+
from ctypes import c_ulong
12+
from ctypes import c_void_p
13+
from ctypes import create_string_buffer
14+
from ctypes import string_at
515
import sys
6-
from ctypes import *
716

8-
if sys.platform == 'win32' or sys.platform == 'cygwin':
17+
18+
if sys.platform in ('win32', 'cygwin'):
919
_eay = CDLL('libeay32.dll')
1020
elif sys.platform == 'darwin':
1121
_eay = CDLL('libcrypto.dylib')

celerytasks/tests/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
from chef import *
2-
from azuretest import *
1+
2+
from azuretest import * # noqa
3+
from chef import * # noqa

deis/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@
250250
# EMAIL_HOST_PASSWORD = 'bar'
251251

252252
# import other settings
253-
from .chef_settings import * # @UnusedWildImport
254-
from .celery_settings import * # @UnusedWildImport
253+
from .chef_settings import * # noqa @UnusedWildImport
254+
from .celery_settings import * # noqa @UnusedWildImport
255255
try:
256-
from .local_settings import * # pylint: disable=W0401 @UnusedWildImport
256+
from .local_settings import * # noqa @UnusedWildImport
257257
except ImportError:
258-
pass
258+
print('No deis/local_settings.py file found!')

requirements.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
azure>=0.7.0
1+
# Deis' python library requirements
22
boto>=2.9.8
33
Django>=1.5.1
44
django-allauth>=0.12.0
@@ -13,3 +13,12 @@ psycopg2>=2.5.1
1313
pyCrypto>=2.6
1414
PyYAML>=3.10
1515
South>=0.8.1
16+
17+
# Windows Azure cloud driver -- not yet required
18+
# azure>=0.7.0
19+
20+
# Generates template documentation in the Django admin.
21+
# docutils>=0.11
22+
23+
# Deis developers must run "flake8" before committing code.
24+
# flake8>=2.0

0 commit comments

Comments
 (0)