• R/O
  • HTTP
  • SSH
  • HTTPS

karesansui: Commit

Git repository of Karesansui.


Commit MetaInfo

Revision4657a8c4f8227b1cc77451dff75b4d30dd8042f7 (tree)
Time2010-07-22 21:10:20
AuthorJunichi Shinohara <junichi@kare...>
CommiterJunichi Shinohara

Log Message

commited

Change Summary

Incremental Difference

--- a/karesansui/gadget/hostby1logby1appby1.py
+++ b/karesansui/gadget/hostby1logby1appby1.py
@@ -128,6 +128,8 @@ class HostBy1LogBy1AppBy1(Rest):
128128 param_value["start_datetime"],
129129 param_value["end_datetime"],
130130 param_value["k"])
131+ if lines is False:
132+ return web.notfound()
131133 except Exception, e:
132134 self.logger.warning("log file open error: %s" % e)
133135 else:
@@ -139,6 +141,8 @@ class HostBy1LogBy1AppBy1(Rest):
139141 param_value["statrt_datetime"],
140142 param_value["end_datetime"],
141143 param_value["k"])
144+ if lines is False:
145+ return web.notfound()
142146 except Exception, e:
143147 self.logger.warning("log file open error: %s" % e)
144148
--- a/karesansui/lib/log/viewer.py
+++ b/karesansui/lib/log/viewer.py
@@ -16,6 +16,7 @@
1616 import re
1717 import time
1818 import os
19+import os.path
1920 import sha
2021 import gzip
2122
@@ -26,7 +27,11 @@ def read_all_log(app_log_config, max_line, start_datetime="", end_datetime="", k
2627
2728 for log in app_log_config['logs']:
2829 log_path = "/var/log/%s/%s" % (log["dir"], log["filename"])
30+ if os.path.isfile(log_path) is False:
31+ return False
2932 lines = read_log(log_path, max_line, log, start_datetime, end_datetime, keyword)
33+ if lines is False:
34+ return False
3035 for line in lines:
3136 key = sha.new(line).hexdigest()
3237 logs.update({key: line})
@@ -60,6 +65,8 @@ def read_log_with_lotate(filename, max_line, log_config, start_datetime="", end_
6065 lines = []
6166 for read_filename in log_dir_list:
6267 log_path = "%s/%s" % (log_dir, read_filename)
68+ if os.path.isfile(log_path) is False:
69+ return False
6370 lines += read_log(log_path, max_line, log_config, start_datetime, end_datetime, keyword)
6471 if len(lines) >= max_line:
6572 return lines[:max_line]
@@ -81,6 +88,9 @@ def is_gzip(fd):
8188 return 0
8289
8390 def read_log(path, max_line, log_config, start_datetime="", end_datetime="", keyword=""):
91+ if os.path.isfile(path) is False:
92+ return False
93+
8494 try:
8595 fd = open(path, "r")
8696 except Exception,e:
Show on old repository browser