aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorDevendra2014-04-23 21:35:06 +0530
committerDevendra2014-04-23 21:35:06 +0530
commitf7b89bfafae34fa22509c1d1c59d1284ec62c5df (patch)
tree2eeaf63f906ade16c82c86844e8f76b191b9ad6c /python
parent1d97c69f186719fe007a4fa0033d39d9a68a4e43 (diff)
downloadpubnub-python-f7b89bfafae34fa22509c1d1c59d1284ec62c5df.tar.bz2
exception handling changes
Diffstat (limited to 'python')
-rw-r--r--python/Pubnub.py37
-rwxr-xr-xpython/examples/dev-console.py26
2 files changed, 25 insertions, 38 deletions
diff --git a/python/Pubnub.py b/python/Pubnub.py
index 93f416b..3bf02a3 100644
--- a/python/Pubnub.py
+++ b/python/Pubnub.py
@@ -186,7 +186,7 @@ import sys
try:
from urllib.parse import quote
-except:
+except ImportError:
from urllib2 import quote
from base64 import urlsafe_b64encode
@@ -397,7 +397,7 @@ class PubnubBase(object):
"""
- message = self.encrypt(args['message'])
+ message = self.encrypt(message)
## Send Message
return self._request({"urlcomponents": [
@@ -458,15 +458,6 @@ class PubnubBase(object):
print(here_now['uuids'])
"""
- channel = str(args['channel'])
-
- callback = args['callback'] if 'callback' in args else None
- error = args['error'] if 'error' in args else None
-
- ## Fail if bad input.
- if not channel:
- raise Exception('Missing Channel')
- return False
## Get Presence Here Now
return self._request({"urlcomponents": [
@@ -807,21 +798,23 @@ class PubnubCoreAsync(PubnubBase):
return
## CONNECT TO PUBNUB SUBSCRIBE SERVERS
- try:
- self.SUB_RECEIVER = self._request({"urlcomponents": [
- 'subscribe',
- self.subscribe_key,
- channel_list,
- '0',
- str(self.timetoken)
- ], "urlparams": {"uuid": self.uuid, "auth": self.auth_key}},
- sub_callback,
- sub_callback,
- single=True)
+ #try:
+ self.SUB_RECEIVER = self._request({"urlcomponents": [
+ 'subscribe',
+ self.subscribe_key,
+ channel_list,
+ '0',
+ str(self.timetoken)
+ ], "urlparams": {"uuid": self.uuid, "auth": self.auth_key}},
+ sub_callback,
+ sub_callback,
+ single=True)
+ '''
except Exception as e:
print(e)
self.timeout(1, _connect)
return
+ '''
self._connect = _connect
diff --git a/python/examples/dev-console.py b/python/examples/dev-console.py
index 2e93c7e..868ba7c 100755
--- a/python/examples/dev-console.py
+++ b/python/examples/dev-console.py
@@ -55,13 +55,13 @@ parser.add_option("--uuid",
print(options)
-pubnub = Pubnub(options.publish_key,
- options.subscribe_key,
- options.secret_key,
- options.cipher_key,
- options.auth_key,
- options.ssl,
- options.origin,
+pubnub = Pubnub(options.publish_key,
+ options.subscribe_key,
+ options.secret_key,
+ options.cipher_key,
+ options.auth_key,
+ options.ssl,
+ options.origin,
options.uuid)
@@ -87,7 +87,7 @@ def print_ok(msg, channel=None):
"] " if channel is not None else "" + color.END
try:
print(chstr + color.GREEN + str(msg) + color.END)
- except Exception as e:
+ except UnicodeEncodeError as e:
print(msg)
@@ -98,7 +98,7 @@ def print_error(msg, channel=None):
"] " if channel is not None else "" + color.END
try:
print(chstr + color.RED + color.BOLD + str(msg) + color.END)
- except:
+ except UnicodeEncodeError as e:
print(msg)
import threading
@@ -107,13 +107,7 @@ import threading
def kill_all_threads():
for thread in threading.enumerate():
if thread.isAlive():
- try:
- thread._Thread__stop()
- except Exception as e:
- pass
- #print(e)
- #thread.exit()
- #print(str(thread.getName()) + ' could not be terminated')
+ thread._Thread__stop()
def get_input(message, t=None):