forked from web2py/web2py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
w2p_clone
executable file
·55 lines (45 loc) · 1.72 KB
/
w2p_clone
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
#!/usr/bin/env python
import os
import sys
"""
Author: Christopher Steel on behalf of Voice of Access
Copyright: Copyrighted (c) by Massimo Di Pierro (2007-2013)
web2py_clone becomes part of the web2py distribution available
on Pypi via 'pip install web2py'
web2py_clone is one of multiple commands that become available after running
'pip install web2py' in a virtual environment. It requires
mercurial to be installed in the virtual environment.
web2py_clone creates a local clone from the Web2py google code
project in the directory "./web2py," a directory called web2py
one directory up from the location of this script.
./bin/web2py_clone
./web2py
"""
def main():
iwd = cwd = os.getcwd() # set initial and current working directories
script_filename = os.path.realpath(__file__)
script_dirname = os.path.dirname(script_filename)
try:
print ("cwd now: %s" % cwd)
except:
print ("command failed %s" % cwd)
try:
os.chdir(script_dirname)
cwd = os.getcwd()
print ("cwd now: %s" % cwd)
source = "https://code.google.com/p/web2py/"
target = os.path.join('..','web2py')
print ("attempting to clone %s" % source)
print ("to %s" % target)
if os.path.isdir(target):
print ("found directory called web2py at %s" % target)
print ("is web2py already installed?")
print ("aborting clone attempt")
else:
os.system("hg clone %s %s" % (source,target))
os.chdir(iwd) # return to our initial working directory
cwd = iwd # set current working directory
except:
print ("web2py-clone failed in second try statement %s" % cwd)
if __name__ == '__main__':
main()