From cbf05be474c95311b12783e795008d94d45493d7 Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 15 Dec 2014 19:46:43 -0500 Subject: [PATCH] Python 3 complatible. --- README.rst | 3 ++- pydash/services.py | 24 ++++++++++++------------ pydash/views.py | 8 ++++---- setup.py | 8 +++++++- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/README.rst b/README.rst index b12e5c6..b784373 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -pyDash - v1.4.5 +pyDash - v1.4.6 =============== A reusable django app for monitoring your linux server. @@ -8,6 +8,7 @@ Supported Python versions: :: Python 2.x + Python 3.x Requirements: diff --git a/pydash/services.py b/pydash/services.py index 6a5f331..f102742 100644 --- a/pydash/services.py +++ b/pydash/services.py @@ -18,7 +18,7 @@ def get_uptime(): uptime_time = str(timedelta(seconds=uptime_seconds)) data = uptime_time.split('.', 1)[0] - except Exception, err: + except Exception as err: data = str(err) return data @@ -51,7 +51,7 @@ def get_ipaddress(): data = ips - except Exception, err: + except Exception as err: data = str(err) return data @@ -75,7 +75,7 @@ def get_cpus(): data = {'cpus': cpus, 'type': data} - except Exception, err: + except Exception as err: data = str(err) return data @@ -95,7 +95,7 @@ def get_users(): else: data = [i.split(None, 3) for i in data] - except Exception, err: + except Exception as err: data = str(err) return data @@ -126,7 +126,7 @@ def get_traffic(request): data = all_traffic - except Exception, err: + except Exception as err: data = str(err) return data @@ -145,7 +145,7 @@ def get_platform(): data = {'osname': osname, 'hostname': uname[1], 'kernel': uname[2]} - except Exception, err: + except Exception as err: data = str(err) return data @@ -163,7 +163,7 @@ def get_disk(): data = [i.split(None, 6) for i in data] - except Exception, err: + except Exception as err: data = str(err) return data @@ -199,7 +199,7 @@ def get_disk_rw(): data = rws - except Exception, err: + except Exception as err: data = str(err) return data @@ -231,7 +231,7 @@ def get_mem(): data = mem_usage - except Exception, err: + except Exception as err: data = str(err) return data @@ -264,7 +264,7 @@ def get_cpu_usage(): data = cpu_used - except Exception, err: + except Exception as err: data = str(err) return data @@ -276,7 +276,7 @@ def get_load(): """ try: data = os.getloadavg()[0] - except Exception, err: + except Exception as err: data = str(err) return data @@ -295,7 +295,7 @@ def get_netstat(): data = [i.split(None, 4) for i in data] - except Exception, err: + except Exception as err: data = str(err) return data diff --git a/pydash/views.py b/pydash/views.py index f838b57..07453ba 100755 --- a/pydash/views.py +++ b/pydash/views.py @@ -280,7 +280,7 @@ def memusage(request): mem_usage = 0 try: - cookies = request._cookies['memory_usage'] + cookies = request.COOKIES['memory_usage'] except Exception: cookies = None @@ -399,7 +399,7 @@ def loadaverage(request): load_average = 0 try: - cookies = request._cookies['load_average'] + cookies = request.COOKIES['load_average'] except Exception: cookies = None @@ -466,7 +466,7 @@ def gettraffic(request): traffic = 0 try: - cookies = request._cookies['traffic'] + cookies = request.COOKIES['traffic'] except Exception: cookies = None @@ -588,7 +588,7 @@ def getdiskio(request): diskrw = 0 try: - cookies = request._cookies['diskrw'] + cookies = request.COOKIES['diskrw'] except Exception: cookies = None diff --git a/setup.py b/setup.py index f5229f8..10a91d0 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-pydash-app', - version='1.4.5', + version='1.4.6', packages=['pydash'], include_package_data=True, license='MIT', @@ -27,6 +27,12 @@ setup( 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.0', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ],