forked from palaniraja/iForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIforceStartNewProject.py
58 lines (47 loc) · 1.71 KB
/
IforceStartNewProject.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
import os
import urllib
import shutil
import sublime, sublime_plugin
def getunzipped(theurl, thedir):
# print 'url:' + theurl
# print 'thedir' + thedir
# print 'test' + test
name = os.path.join(thedir, 'temp.zip')
try:
name, hdrs = urllib.urlretrieve(theurl, name)
except IOError as e:
print ("iForce: Can't retrieve %r to %r: %s" % (theurl, thedir, e))
return
try:
extract(name, thedir)
os.unlink(name)
except zipfile.error as e:
print ("iForce: Bad zipfile (from %r): %s" % (theurl, e))
return
class IforceStartNewProjectCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(IforceStartNewProjectCommand, self).__init__(*args, **kwargs)
def on_done(self, dirname):
# print 'dirname: ' + dirname
outputdir = dirname
iforce_path = sublime.packages_path() + '/iForceTest'
# copy build files to folder
shutil.copy(iforce_path + '/iForce_build.xml', outputdir)
shutil.copy(iforce_path + '/iForce_build.properties', outputdir)
# copy package.xml and generate project folders
shutil.copy(iforce_path + '/package.xml', outputdir)
for folder in ['classes', 'components', 'pages', 'triggers']:
if not os.path.exists(outputdir + '/' + folder):
os.makedirs(outputdir + '/' + folder)
# print 'outputdir: '+ self.outputdir
print ('iForce: iforce_start_new_project [DONE]')
def run(self, *args, **kwargs):
initialFolder = self.window.folders()[0]
# print 'Archive: ' + self.sfTempArchive
self.window.show_input_panel(
"iForce: Select a location to setup this project: ",
initialFolder,
self.on_done,
None,
None
)