-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate_project.py
executable file
·80 lines (63 loc) · 2.42 KB
/
create_project.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pipe.am.pipeline_io as pipeline_io
import os
import sys
import json
import subprocess
project_dict = {"reference_dir": "production/reference_geo/",
"name": "TestProject",
"assets_dir": "production/assets/",
"users_dir": "production/users/",
"nickname": "test",
"crowds_dir": "production/crowds/",
"tools_dir": "production/tools/",
"templates_dir": "production/templates/",
"shots_dir": "production/rendered_shots/",
"email_address": "[email protected]",
"hda_dir": "production/hdas/",
"email_password": "password",
"production_dir": "production/"}
'''
Python script to initialize the production side of the pipe.
Usage - python create_project.py nameOfProject nicknameOfProject
'''
def create_project():
if not len(sys.argv) == 3:
print("Create project failed. Invalid number of arguments.")
print("Usage - python create_project.py nameOfProject nicknameOfProject")
return
project_dir = os.getenv("MEDIA_PROJECT_DIR")
# get the command line arguments 1 - name, 2 - nickname
name = sys.argv[1]
nickname = sys.argv[2]
create_project_config()
modify_project_config(name, nickname)
pipe_dict = pipeline_io.readfile(".project")
pipeline_io.mkdir(pipe_dict["production_dir"])
pipeline_io.mkdir(pipe_dict["assets_dir"])
pipeline_io.mkdir(pipe_dict["crowds_dir"])
pipeline_io.mkdir(pipe_dict["shots_dir"])
pipeline_io.mkdir(pipe_dict["tools_dir"])
pipeline_io.mkdir(pipe_dict["users_dir"])
pipeline_io.mkdir(pipe_dict["hda_dir"])
pipeline_io.mkdir(pipe_dict["reference_dir"])
create_project_shortcuts(nickname=nickname, name=name)
print("Production project successfully created!")
def create_project_config():
with open(".project", "w") as jsonFile:
json.dump(project_dict, jsonFile)
def modify_project_config(name, nickname):
with open(".project", "r") as jsonFile:
data = json.load(jsonFile)
# tmp = data["name"]
data["name"] = name
data["nickname"] = nickname
with open(".project", "w") as jsonFile:
json.dump(data, jsonFile)
def create_project_shortcuts(nickname="test", name="test"):
cwd = os.getcwd()
icon_script = os.path.join(cwd, 'create_project_shortcuts.sh')
if(nickname is not None):
subprocess.call(['sh', icon_script, '-n', nickname, name, cwd])
else:
subprocess.call(['sh', icon_script, name, cwd])
create_project()