-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
57 lines (40 loc) · 1.46 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import shutil
import sys
from setuptools import setup
from setuptools.command.install import install
if sys.version_info < (3,):
sys.exit("Sorry, Python < 3.x is not supported")
SRC_CONFIG_FILE = 'config/workstations.cfg'
DEST_CONFIG_FILE = os.path.join(sys.prefix, 'etc', 'autobackup.cfg')
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
self._install_config_file()
self._print_cron_update_cmd()
def _install_config_file(self):
src_config = SRC_CONFIG_FILE
dest_config = DEST_CONFIG_FILE
self._mk_config_file_dir(dest_config)
print("copying {} -> {}".format(src_config, dest_config))
shutil.copy(src_config, dest_config)
def _mk_config_file_dir(self, dest_config):
dirname = os.path.dirname(dest_config)
if not os.path.exists(dirname):
os.mkdir(dirname)
def _print_cron_update_cmd(self):
print("To run autobackup every day at 2:00 am, update the crontab:")
print("0 2 * * * root /usr/local/bin/autobackup")
requirements = []
test_requirements = []
setup(
name='autobackup',
version="1.1.0",
description='A simple backup utility',
author='Benoist LAURENT',
author_email='[email protected]',
url='https://github.com/benoistlaurent/autobackup',
scripts=['scripts/autobackup'],
cmdclass={'install': PostInstallCommand}
)