Commits

desmaj committed 4e9043d

cleaned up json library selection a bit; removed some stray and deadly imports from the functional test modules; added a pip requirement file that requires libraries you'd use for development

Comments (0)

Files changed (6)

daemon/development.req

+nose
+objgraph
+simplejson

daemon/orbited/json.py

 Select a JSON library from any of several known libraries.
 """
 
-try:
-    import cjson
-    encode = cjson.encode
-    decode = cjson.decode
-except ImportError:
+modules = [('json', 'dumps', 'loads'), 
+           ('cjson', 'encode', 'decode'), 
+           ('simplejson', 'dumps', 'loads'),
+           ('demjson', 'encode', 'decode'),
+          ]
+
+while modules:
+    module_name, serializer, deserializer = modules.pop(0)
     try:
-        import simplejson
-        encode = simplejson.dumps
-        decode = simplejson.loads
+        json = __import__(module_name)
+        encode = getattr(json, serializer)
+        decode = getattr(json, deserializer)
+        break
     except ImportError:
-        try:
-            import demjson
-            encode = demjson.encode
-            decode = demjson.decode
-        except ImportError:
-            raise ImportError, "could not load one of: cjson, simplejson, demjson"
-        
+        if not modules:
+            raise ImportError,\
+                "could not load one of: json, cjson, simplejson, demjson"
+

daemon/orbited/test/functional/test_cross_port_tcp_socket.py

-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestCrossPortTCPSocket(TCPSocketTestCase):

daemon/orbited/test/functional/test_cross_subdomain_tcp_socket.py

-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestCrossSubdomainTCPSocket(TCPSocketTestCase):

daemon/orbited/test/functional/test_same_domain_tcp_socket.py

-from selenium import selenium
-import time, re
-
 from orbited.test.functional import TCPSocketTestCase
 
 class TestSameDomainTCPSocket(TCPSocketTestCase):
Add a comment to this file

daemon/orbited/test/resources/__init__.py

Empty file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.