Mercurial > feed-push
comparison feed-push @ 34:030e8b24f8b7 draft default tip master
pretty print JSON in state file
Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author | Changaco <changaco ατ changaco δοτ net> |
---|---|
date | Sun, 05 Aug 2012 15:18:28 +0200 |
parents | adde3e451237 |
children |
comparison
equal
deleted
inserted
replaced
33:adde3e451237 | 34:030e8b24f8b7 |
---|---|
180 else: | 180 else: |
181 ignore_event(path, event) | 181 ignore_event(path, event) |
182 | 182 |
183 def save_state(): | 183 def save_state(): |
184 global_args.state_file.truncate(0) | 184 global_args.state_file.truncate(0) |
185 json.dump(state, global_args.state_file) | 185 if global_args.pretty: |
186 json.dump(state, global_args.state_file, indent=4) | |
187 else: | |
188 json.dump(state, global_args.state_file) | |
186 global_args.state_file.flush() | 189 global_args.state_file.flush() |
187 | 190 |
188 | 191 |
189 # Commands utils | 192 # Commands utils |
190 | 193 |
281 p.add_argument('config', type=FirstOf(AbsPath(argparse.FileType('r')), AbsPath(Directory), error='"{}" is neither a file nor a directory'), help='either a file or a directory') | 284 p.add_argument('config', type=FirstOf(AbsPath(argparse.FileType('r')), AbsPath(Directory), error='"{}" is neither a file nor a directory'), help='either a file or a directory') |
282 p.add_argument('state_file', type=MakeDirs(argparse.FileType('a+')), help='e.g. /var/lib/feed-push/state') | 285 p.add_argument('state_file', type=MakeDirs(argparse.FileType('a+')), help='e.g. /var/lib/feed-push/state') |
283 p.add_argument('--flood', default=False, action='store_true', help='push all articles on startup instead of ignoring the ones older than 24h (useful for debugging)') | 286 p.add_argument('--flood', default=False, action='store_true', help='push all articles on startup instead of ignoring the ones older than 24h (useful for debugging)') |
284 p.add_argument('--fork', metavar='pid-file', nargs=1, type=File(os.O_WRONLY|os.O_CREAT|os.O_EXCL), action=First, help='daemonize and log to syslog') | 287 p.add_argument('--fork', metavar='pid-file', nargs=1, type=File(os.O_WRONLY|os.O_CREAT|os.O_EXCL), action=First, help='daemonize and log to syslog') |
285 p.add_argument('--log-level', nargs=1, default=1, choices=log_levels, action=partial(Apply, log_levels.index), help='default is INFO') | 288 p.add_argument('--log-level', nargs=1, default=1, choices=log_levels, action=partial(Apply, log_levels.index), help='default is INFO') |
289 p.add_argument('--no-pretty', dest='pretty', default=True, action='store_false', help='don\'t pretty print JSON in state file') | |
286 global_args = p.parse_args() | 290 global_args = p.parse_args() |
287 | 291 |
288 if global_args.fork: | 292 if global_args.fork: |
289 pid = os.fork() | 293 pid = os.fork() |
290 if pid != 0: | 294 if pid != 0: |