summaryrefslogtreecommitdiffstats
path: root/install.py
blob: 520a347d8b1a6df49c0bf0875366b242a26f1465 (plain) (blame)
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
#!/usr/bin/env python

################################################################################
# Description
################################################################################

# This script installes (or re-installs) the unit_trace Python module, so that
# the unit_trace library can be imported with `import unit_trace` by a Python
# script, from anywhere on the system.

# The installation merely copies the unit-trace script and the unit_trace
# folder to ~/bin. You can also do this manually if you want to.

# We do not use the Distutils system, provided by Python, because that
# is less convenient :-)


################################################################################
# Imports
################################################################################

import sys
import shutil
import os


################################################################################
# Do the install
################################################################################

# Determine destination directory for unit_trace module
dst = '~/bin/unit_trace'
dst = os.path.expanduser(dst)

try:
    # If the destination exists
    if os.path.exists(dst):
        # Delete it
        shutil.rmtree(dst)
    # Copy source to destination
    shutil.copytree('unit_trace', dst)
except:
    print "Unexpected error:", sys.exc_info()
    exit()

# Determine destination directory for unit-trace script
dst = '~/bin/unit-trace'
dst = os.path.expanduser(dst)
try:
    shutil.copyfile('unit-trace', dst)
    # Keep same permissions
    shutil.copystat('unit-trace', dst)
except:
    print "Unexpected error:", sys.exc_info()
    exit()