Merge lp:~bcsaller/amulet/fix-urlencode into lp:~marcoceppi/amulet/master

Proposed by Benjamin Saller
Status: Needs review
Proposed branch: lp:~bcsaller/amulet/fix-urlencode
Merge into: lp:~marcoceppi/amulet/master
Diff against target: 98 lines (+25/-15)
6 files modified
.bzrignore (+5/-0)
Makefile (+1/-1)
amulet/charms/sentry/src/api.py (+4/-11)
amulet/charms/sentry/src/modules/__init__.py (+3/-0)
amulet/deployer.py (+6/-0)
amulet/sentry.py (+6/-3)
To merge this branch: bzr merge lp:~bcsaller/amulet/fix-urlencode
Reviewer Review Type Date Requested Status
Marco Ceppi Pending
Review via email: mp+203885@code.launchpad.net

Description of the change

Various Python2/3 compat issues

Also removes some dynamic module loading which didn't seem to
add any value.

https://codereview.appspot.com/55020045/

To post a comment you must log in.
Revision history for this message
Benjamin Saller (bcsaller) wrote :
Download full text (3.6 KiB)

Reviewers: mp+203885_code.launchpad.net,

Message:
Please take a look.

Description:
Various Python2/3 compat issues

Also removes some dynamic module loading which didn't seem to
add any value.

https://code.launchpad.net/~bcsaller/amulet/fix-urlencode/+merge/203885

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/55020045/

Affected files (+27, -15 lines):
   A .bzrignore
   M Makefile
   A [revision details]
   M amulet/charms/sentry/src/api.py
   M amulet/charms/sentry/src/modules/__init__.py
   M amulet/deployer.py
   M amulet/sentry.py

Index: .bzrignore
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2014-01-30 07:41:13 +0000
@@ -0,0 +1,5 @@
+.coverage
+amulet.egg-info/
+venv/
+amulet/.ropeproject/
+

Index: Makefile
=== modified file 'Makefile'
--- Makefile 2014-01-24 15:52:45 +0000
+++ Makefile 2014-01-30 07:40:10 +0000
@@ -55,7 +55,7 @@
   $(PIP) install -r test-requires.txt

  .PHONY: test
-test: $(NOSE)
+test: install $(NOSE)
   make py3test

  # This is a private target used to get around finding nose in different
paths.

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: git-v1:a1911cbb8d7bcae6e0feaa249a55a3f5cdf6126d
+New revision: <email address hidden>

Index: amulet/deployer.py
=== modified file 'amulet/deployer.py'
--- amulet/deployer.py 2014-01-24 16:05:57 +0000
+++ amulet/deployer.py 2014-01-30 07:40:10 +0000
@@ -16,6 +16,12 @@
  from . import wait
  from .charm import Builder

+try:
+ TimeoutError
+except NameError:
+ class TimeoutError(OSError):
+ pass
+

  _default_sentry_template = os.path.join(
      os.path.abspath(os.path.dirname(__file__)), 'charms/sentry')

Index: amulet/sentry.py
=== modified file 'amulet/sentry.py'
--- amulet/sentry.py 2014-01-24 17:41:01 +0000
+++ amulet/sentry.py 2014-01-30 07:40:10 +0000
@@ -1,11 +1,14 @@
-
-import urllib
  import requests

  from . import waiter
  from . import helpers
  from . import charmstore

+try:
+ from urllib.parse import urlencode
+except ImportError:
+ from urllib import urlencode
+

  class SentryError(Exception):
      pass
@@ -44,7 +47,7 @@
          return self._fetch(self.config['address'], endpoint, query, data)

      def _fetch(self, address, endpoint, query={}, data=None):
- url = "%s/%s?%s" % (address, endpoint,
urllib.parse.urlencode(query))
+ url = "%s/%s?%s" % (address, endpoint, urlencode(query))
          if data:
              return requests.post(url, data=data, verify=False)
          else:

Index: amulet/charms/sentry/src/api.py
=== modified file 'amulet/charms/sentry/src/api.py'
--- amulet/charms/sentry/src/api.py 2014-01-22 21:41:24 +0000
+++ amulet/charms/sentry/src/api.py 2014-01-30 07:40:10 +0000
@@ -1,12 +1,5 @@
-
-import pkgutil
-
-
-modules = []
-for i in [name for _, name, _ in pkgutil.iter_modules(['modules'])]:
- exec("from modules.%s import Module" % i)
- exec("modules.append(Module)")
-
-
-class API (*modules):
+from .mod...

Read more...

Unmerged revisions

123. By Benjamin Saller

bzrignore

122. By Benjamin Saller

some 2/3 compat issues

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2014-01-30 07:42:22 +0000
4@@ -0,0 +1,5 @@
5+.coverage
6+amulet.egg-info/
7+venv/
8+amulet/.ropeproject/
9+
10
11=== modified file 'Makefile'
12--- Makefile 2014-01-24 15:52:45 +0000
13+++ Makefile 2014-01-30 07:42:22 +0000
14@@ -55,7 +55,7 @@
15 $(PIP) install -r test-requires.txt
16
17 .PHONY: test
18-test: $(NOSE)
19+test: install $(NOSE)
20 make py3test
21
22 # This is a private target used to get around finding nose in different paths.
23
24=== modified file 'amulet/charms/sentry/src/api.py'
25--- amulet/charms/sentry/src/api.py 2014-01-22 21:41:24 +0000
26+++ amulet/charms/sentry/src/api.py 2014-01-30 07:42:22 +0000
27@@ -1,12 +1,5 @@
28-
29-import pkgutil
30-
31-
32-modules = []
33-for i in [name for _, name, _ in pkgutil.iter_modules(['modules'])]:
34- exec("from modules.%s import Module" % i)
35- exec("modules.append(Module)")
36-
37-
38-class API (*modules):
39+from .modules import docs, filesystem, juju, relations, run
40+
41+
42+class API (docs, filesystem, juju, relations, run):
43 pass
44
45=== modified file 'amulet/charms/sentry/src/modules/__init__.py'
46--- amulet/charms/sentry/src/modules/__init__.py 2013-10-04 16:29:48 +0000
47+++ amulet/charms/sentry/src/modules/__init__.py 2014-01-30 07:42:22 +0000
48@@ -0,0 +1,3 @@
49+import docs, filesystem, juju, relations, run
50+
51+__all__ = ['docs', 'filesystem', 'juju', 'relations', 'run']
52
53=== modified file 'amulet/deployer.py'
54--- amulet/deployer.py 2014-01-24 16:05:57 +0000
55+++ amulet/deployer.py 2014-01-30 07:42:22 +0000
56@@ -16,6 +16,12 @@
57 from . import wait
58 from .charm import Builder
59
60+try:
61+ TimeoutError
62+except NameError:
63+ class TimeoutError(OSError):
64+ pass
65+
66
67 _default_sentry_template = os.path.join(
68 os.path.abspath(os.path.dirname(__file__)), 'charms/sentry')
69
70=== modified file 'amulet/sentry.py'
71--- amulet/sentry.py 2014-01-24 17:41:01 +0000
72+++ amulet/sentry.py 2014-01-30 07:42:22 +0000
73@@ -1,11 +1,14 @@
74-
75-import urllib
76 import requests
77
78 from . import waiter
79 from . import helpers
80 from . import charmstore
81
82+try:
83+ from urllib.parse import urlencode
84+except ImportError:
85+ from urllib import urlencode
86+
87
88 class SentryError(Exception):
89 pass
90@@ -44,7 +47,7 @@
91 return self._fetch(self.config['address'], endpoint, query, data)
92
93 def _fetch(self, address, endpoint, query={}, data=None):
94- url = "%s/%s?%s" % (address, endpoint, urllib.parse.urlencode(query))
95+ url = "%s/%s?%s" % (address, endpoint, urlencode(query))
96 if data:
97 return requests.post(url, data=data, verify=False)
98 else:

Subscribers

People subscribed via source and target branches