Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/olpc/datastore/bin_copy.py
blob: 1be1b6bfe000d440aa42341dcf2c7a9362417efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os, subprocess


def bin_copy(src, dest, mode=0600):
    try:
        subprocess.check_call(['/bin/cp', src, dest])
    except subprocess.CalledProcessError:
        raise OSError("Copy failed %s %s" % (src, dest))
    else:
        os.chmod(dest, mode)


if __name__ == "__main__":
    import sys
    if len(sys.argv) != 3:
        raise SystemExit("usage: <src> <dest>")
    
    src, dest = sys.argv[1:]
    
    if not os.path.exists(src): raise OSError("missing src file")

    bin_copy(src, dest)