Browse Source

db, queries, and updates work in python 2

Keith Newman 10 years ago
parent
commit
538cb2f1c9

+ 12 - 0
frameworks/Python/cherrypy/README.md

@@ -22,3 +22,15 @@ http://localhost:8080/json
 ### Plaintext
 
 http://localhost:8080/plaintext
+
+### DB
+
+http://localhost:8080/db
+
+### Query
+
+http://localhost:8080/queries?queries=2
+
+### Update
+
+http://localhost:8080/updates?queries=2

+ 10 - 3
frameworks/Python/cherrypy/app.py

@@ -11,6 +11,14 @@ from sqlalchemy.types import String, Integer
 
 Base = declarative_base()
 
+
+def getQueryNum(queryString):
+  try:
+    int(queryString)
+    return int(queryString)
+  except ValueError:
+    return 1
+
 class Fortune(Base):
   __tablename__ = "fortune"
 
@@ -54,7 +62,7 @@ class CherryPyBenchmark(object):
   @cherrypy.expose
   @cherrypy.tools.json_out()
   def queries(self, queries=1):
-    num_queries = int(queries)
+    num_queries = getQueryNum(queries)
     if num_queries < 1:
       num_queries = 1
     if num_queries > 500:
@@ -69,7 +77,7 @@ class CherryPyBenchmark(object):
   @cherrypy.tools.json_out()
   def updates(self, queries=1):
     cherrypy.response.headers["Content-Type"] = "application/json"
-    num_queries = int(queries)
+    num_queries = getQueryNum(queries)
     if num_queries < 1:
       num_queries = 1
     if num_queries > 500:
@@ -86,7 +94,6 @@ class CherryPyBenchmark(object):
     return worlds
 
 if __name__ == "__main__":
-    print "HELLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO~~~~~~~~~~~~~~"
     # Register the SQLAlchemy plugin
     from saplugin import SAEnginePlugin
     DBDRIVER = 'mysql'

+ 6 - 6
frameworks/Python/cherrypy/benchmark_config

@@ -5,16 +5,16 @@
       "setup_file": "setup",
       "json_url": "/json",
       "db_url": "/db",
-      "query_url": "/queries?quries=",
+      "query_url": "/queries?queries=",
       "update_url": "/updates?queries=",
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Micro",
-      "database": "None",
+      "database": "MySQL",
       "framework": "cherrypy",
       "language": "Python",
-      "orm": "Raw",
+      "orm": "Full",
       "platform": "CherryPy",
       "webserver": "None",
       "os": "Linux",
@@ -26,16 +26,16 @@
       "setup_file": "setup_py3",
       "json_url": "/json",
       "db_url": "/db",
-      "query_url": "/queries?quries=",
+      "query_url": "/queries?queries=",
       "update_url": "/updates?queries=",
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Micro",
-      "database": "None",
+      "database": "MySQL",
       "framework": "cherrypy",
       "language": "Python",
-      "orm": "Raw",
+      "orm": "Full",
       "platform": "CherryPy",
       "webserver": "None",
       "os": "Linux",

+ 1 - 1
frameworks/Python/cherrypy/install.sh

@@ -7,5 +7,5 @@ fw_depends python2 python3
 
 $PY2_PIP install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/requirements.txt
 
-#$PY3_PIP install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt
+$PY3_PIP install --install-option="--prefix=${PY3_ROOT}" -r $TROOT/requirements.txt
 

+ 1 - 2
frameworks/Python/cherrypy/requirements.txt

@@ -1,4 +1,3 @@
 cherrypy==3.6.0
 SQLAlchemy==0.9.9
-mysqlclient==1.3.1
-MySQL-python==1.2.5
+mysqlclient==1.3.6