diff options
| -rw-r--r-- | beinc_config_sample.json | 1 | ||||
| -rw-r--r-- | beinc_weechat.py | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/beinc_config_sample.json b/beinc_config_sample.json index e200689..6266589 100644 --- a/beinc_config_sample.json +++ b/beinc_config_sample.json | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | "target_password": "changeme", | 31 | "target_password": "changeme", |
| 32 | "target_cert_file": "", | 32 | "target_cert_file": "", |
| 33 | "target_timestamp_format": "%H:%M:%S", | 33 | "target_timestamp_format": "%H:%M:%S", |
| 34 | "socket_timeout": 30, | ||
| 34 | "pm_title_template": "%s @ %S", | 35 | "pm_title_template": "%s @ %S", |
| 35 | "pm_message_template": "%m", | 36 | "pm_message_template": "%m", |
| 36 | "cm_title_template": "%c @ %S", | 37 | "cm_title_template": "%c @ %S", |
diff --git a/beinc_weechat.py b/beinc_weechat.py index b66501b..a8082b7 100644 --- a/beinc_weechat.py +++ b/beinc_weechat.py | |||
| @@ -117,6 +117,7 @@ class WeechatTarget(object): | |||
| 117 | '%H:%M:%S') | 117 | '%H:%M:%S') |
| 118 | self.__debug = bool(target_dict.get('debug', False)) | 118 | self.__debug = bool(target_dict.get('debug', False)) |
| 119 | self.__enabled = bool(target_dict.get('enabled', True)) | 119 | self.__enabled = bool(target_dict.get('enabled', True)) |
| 120 | self.__socket_timeout = int(target_dict.get('socket_timeout', 30)) | ||
| 120 | 121 | ||
| 121 | @property | 122 | @property |
| 122 | def name(self): | 123 | def name(self): |
| @@ -300,9 +301,9 @@ class WeechatTarget(object): | |||
| 300 | global global_beinc_cert_file | 301 | global global_beinc_cert_file |
| 301 | global_beinc_cert_file = self.__cert_file | 302 | global_beinc_cert_file = self.__cert_file |
| 302 | opener = urllib2.build_opener(ValidHTTPSHandler) | 303 | opener = urllib2.build_opener(ValidHTTPSHandler) |
| 303 | response = opener.open(req) | 304 | response = opener.open(req, timeout=self.__socket_timeout) |
| 304 | else: | 305 | else: |
| 305 | response = urllib2.urlopen(req) | 306 | response = urllib2.urlopen(req, self.__socket_timeout) |
| 306 | res_code = response.code | 307 | res_code = response.code |
| 307 | response.close() | 308 | response.close() |
| 308 | if res_code == 200: | 309 | if res_code == 200: |
