Mercurial > kallithea
comparison pylons_app/lib/backup_manager.py @ 241:48727add84c9
Made repos path config configurable from pylons app configs. update Readme
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 30 May 2010 22:08:21 +0200 |
parents | 787e7d307b69 |
children | 3782a6d698af |
comparison
equal
deleted
inserted
replaced
240:7c4fa2a66195 | 241:48727add84c9 |
---|---|
8 import subprocess | 8 import subprocess |
9 logging.basicConfig(level=logging.DEBUG, | 9 logging.basicConfig(level=logging.DEBUG, |
10 format="%(asctime)s %(levelname)-5.5s %(message)s") | 10 format="%(asctime)s %(levelname)-5.5s %(message)s") |
11 | 11 |
12 class BackupManager(object): | 12 class BackupManager(object): |
13 def __init__(self): | 13 def __init__(self, id_rsa_path, repo_conf): |
14 self.repos_path = None | 14 self.repos_path = None |
15 self.backup_file_name = None | 15 self.backup_file_name = None |
16 self.id_rsa_path = '/home/pylons/id_rsa' | 16 self.id_rsa_path = id_rsa_path |
17 self.check_id_rsa() | 17 self.check_id_rsa() |
18 cur_dir = os.path.realpath(__file__) | 18 cur_dir = os.path.realpath(__file__) |
19 dn = os.path.dirname | 19 dn = os.path.dirname |
20 self.backup_file_path = os.path.join(dn(dn(dn(cur_dir))), 'data') | 20 self.backup_file_path = os.path.join(dn(dn(dn(cur_dir))), 'data') |
21 cfg = config.config() | 21 cfg = config.config() |
22 try: | 22 try: |
23 cfg.read(os.path.join(dn(dn(dn(cur_dir))), 'hgwebdir.config')) | 23 cfg.read(os.path.join(dn(dn(dn(cur_dir))), repo_conf)) |
24 except IOError: | 24 except IOError: |
25 logging.error('Could not read hgwebdir.config') | 25 logging.error('Could not read %s', repo_conf) |
26 sys.exit() | 26 sys.exit() |
27 self.set_repos_path(cfg.items('paths')) | 27 self.set_repos_path(cfg.items('paths')) |
28 logging.info('starting backup for %s', self.repos_path) | 28 logging.info('starting backup for %s', self.repos_path) |
29 logging.info('backup target %s', self.backup_file_path) | 29 logging.info('backup target %s', self.backup_file_path) |
30 | 30 |
78 os.remove(os.path.join(self.backup_file_path, self.backup_file_name)) | 78 os.remove(os.path.join(self.backup_file_path, self.backup_file_name)) |
79 | 79 |
80 | 80 |
81 | 81 |
82 if __name__ == "__main__": | 82 if __name__ == "__main__": |
83 B_MANAGER = BackupManager() | 83 B_MANAGER = BackupManager('/home/pylons/id_rsa', 'repositories.config') |
84 B_MANAGER.backup_repos() | 84 B_MANAGER.backup_repos() |
85 B_MANAGER.transfer_files() | 85 B_MANAGER.transfer_files() |
86 B_MANAGER.rm_file() | 86 B_MANAGER.rm_file() |
87 | 87 |
88 | 88 |