-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessing
executable file
·73 lines (55 loc) · 2.19 KB
/
processing
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# https://www.guru99.com/python-check-if-file-exists.html
# https://curl.trillworks.com/
import sys, getopt, subprocess
import argparse
# import requests
import os, glob
import shutil
parser = argparse.ArgumentParser(prog='basic processing sketch', usage='%(prog)s [options] type -h for help')
parser.add_argument("projectName", help="name of the sketch you would like to create")
args = parser.parse_args()
print('\nCreating %s' %args.projectName )
ORIGINAL_NAME = "Plotter"
includeRepo = raw_input("\nAdd a .git repo? [y/n] (default is no ) ")
className = raw_input("\nClassname? (default Canvas) ")
def cloneRepo():
bashCommand = "git clone -b Starting_Template --single-branch https://github.com/fdiazsmith/Plotter.git"
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
print output
print error
def rename( ):
# make a duplicate of an existing file
if os.path.exists(ORIGINAL_NAME):
print("path does exist")
# get the path to the file in the current directory
# src = os.path.realpath(ORIGINAL_NAME);
# print("what is the real path %s" %src)
os.rename( ORIGINAL_NAME, args.projectName )
for filename in os.listdir(args.projectName):
if filename.startswith(ORIGINAL_NAME):
title, ext = os.path.splitext(filename)
print("found match %s" %os.path.join(args.projectName, args.projectName + ext))
os.rename(os.path.join(args.projectName, filename), os.path.join(args.projectName, args.projectName + ext))
# os.rename(filename, args.projectName)
# rename the original file
def removeGit():
shutil.rmtree(os.path.join(args.projectName, ".git"), ignore_errors=True)
def addGit():
bashCommand = "cd "+args.projectName+" && git init"
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
print output
print error
def quit():
pass
if __name__ == "__main__":
try:
cloneRepo()
rename()
removeGit()
if includeRepo == "y":
addGit()
except KeyboardInterrupt:
quit()