-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·52 lines (43 loc) · 1.88 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
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#===============================================================================
# Written by Rentouch 2012 - http://www.rentouch.ch
#===============================================================================
import os
import shutil
import sys
def install():
#search pbase folder
home=os.path.expanduser("~")
git=os.getcwd()
if not os.path.isdir(os.path.join(home, "PBase")):
print "can not locate ~/PBase folder"
return
#create PBase/PBController folder if it doesn't exist
if not os.path.isdir(os.path.join(home, "PBase/PBController")):
os.mkdir(os.path.join(home, "PBase/PBController"))
#change to the PBase/PBController directory
os.chdir(os.path.join(home, "PBase/PBController"))
#check for dev-version file
#if it exists, don't install!- it means that it is a developement version
if os.path.isfile('dev-version'):
print "Don't install! - dev-version file found"
sys.stderr.write('is dev-version')
return
#check if data directory already exist, if not create it with initial
if not os.path.isdir("data"):
shutil.copytree(os.path.join(git, "data"), "data")
#overwrite all files except
for filename in os.listdir(git):
if os.path.isfile(os.path.join(git, filename)) and filename[0]!=".":
if os.path.isfile(filename):
os.remove(filename)
shutil.copy(os.path.join(git, filename), filename)
#overwrite all folders except data
for foldername in os.listdir(git):
if os.path.isdir(os.path.join(git, foldername)) and foldername[0]!=".":
if foldername!="data":
if os.path.isdir(foldername):
shutil.rmtree(foldername)
shutil.copytree(os.path.join(git, foldername), foldername)
install()