Git repository of Karesansui.
Revision | 4657a8c4f8227b1cc77451dff75b4d30dd8042f7 (tree) |
---|---|
Time | 2010-07-22 21:10:20 |
Author | Junichi Shinohara <junichi@kare...> |
Commiter | Junichi Shinohara |
commited
@@ -128,6 +128,8 @@ class HostBy1LogBy1AppBy1(Rest): | ||
128 | 128 | param_value["start_datetime"], |
129 | 129 | param_value["end_datetime"], |
130 | 130 | param_value["k"]) |
131 | + if lines is False: | |
132 | + return web.notfound() | |
131 | 133 | except Exception, e: |
132 | 134 | self.logger.warning("log file open error: %s" % e) |
133 | 135 | else: |
@@ -139,6 +141,8 @@ class HostBy1LogBy1AppBy1(Rest): | ||
139 | 141 | param_value["statrt_datetime"], |
140 | 142 | param_value["end_datetime"], |
141 | 143 | param_value["k"]) |
144 | + if lines is False: | |
145 | + return web.notfound() | |
142 | 146 | except Exception, e: |
143 | 147 | self.logger.warning("log file open error: %s" % e) |
144 | 148 |
@@ -16,6 +16,7 @@ | ||
16 | 16 | import re |
17 | 17 | import time |
18 | 18 | import os |
19 | +import os.path | |
19 | 20 | import sha |
20 | 21 | import gzip |
21 | 22 |
@@ -26,7 +27,11 @@ def read_all_log(app_log_config, max_line, start_datetime="", end_datetime="", k | ||
26 | 27 | |
27 | 28 | for log in app_log_config['logs']: |
28 | 29 | log_path = "/var/log/%s/%s" % (log["dir"], log["filename"]) |
30 | + if os.path.isfile(log_path) is False: | |
31 | + return False | |
29 | 32 | lines = read_log(log_path, max_line, log, start_datetime, end_datetime, keyword) |
33 | + if lines is False: | |
34 | + return False | |
30 | 35 | for line in lines: |
31 | 36 | key = sha.new(line).hexdigest() |
32 | 37 | logs.update({key: line}) |
@@ -60,6 +65,8 @@ def read_log_with_lotate(filename, max_line, log_config, start_datetime="", end_ | ||
60 | 65 | lines = [] |
61 | 66 | for read_filename in log_dir_list: |
62 | 67 | log_path = "%s/%s" % (log_dir, read_filename) |
68 | + if os.path.isfile(log_path) is False: | |
69 | + return False | |
63 | 70 | lines += read_log(log_path, max_line, log_config, start_datetime, end_datetime, keyword) |
64 | 71 | if len(lines) >= max_line: |
65 | 72 | return lines[:max_line] |
@@ -81,6 +88,9 @@ def is_gzip(fd): | ||
81 | 88 | return 0 |
82 | 89 | |
83 | 90 | 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 | + | |
84 | 94 | try: |
85 | 95 | fd = open(path, "r") |
86 | 96 | except Exception,e: |