-
Notifications
You must be signed in to change notification settings - Fork 5
/
UpdateSetup.py
189 lines (150 loc) · 6.79 KB
/
UpdateSetup.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
__author__ = 'Alexey Kostromin'
import os
import subprocess
from Tkinter import *
import glob, shutil
import fileinput
#from ttk import Frame, Button, Style, Label
DistrDir = "C:\\Users\\Alexey\\Documents\\dev\\1c\\1CI\\Distr"
SetupDir = "C:\\Users\\Alexey\\Documents\\dev\\1c\\1CI\\Setup"
ConfDir = "C:\\Users\\Alexey\\Documents\\dev\\1c\\1CI\\"
ConfUser = "Administrator"
DemoDBUser = "Administrator"
RepDir = "C:\\Users\\Alexey\\Documents\\dev\\1c\\1CI\\Repository"
RepUserName = "Administrator"
RepPassword = "123"
ConfPass = ""
DemoDBDir = "C:\\Users\\Alexey\\Documents\\dev\\1c\\1CI\\Demo"
AppPath = "C:\\Program Files (x86)\\1cv8\\8.3.9.1818\\bin\\1cv8.exe"
def MakeDistr(lastReleaseDirName, nextReleaseDirName = None, update = False):
if update:
WorkingDir = DistrDir + "\\" + lastReleaseDirName
nextReleaseDirName = lastReleaseDirName
else:
if lastReleaseDirName == nextReleaseDirName:
print ("lastReleaseDirName and nextReleaseDirName are the same.")
return False
WorkingDir = DistrDir + "\\" + nextReleaseDirName
#dump distr conf file
try:
subprocess.check_call([AppPath, 'DESIGNER', '/F', ConfDir, '/N' , ConfUser, '/CreateDistributionFiles','-cffile' , WorkingDir + '\\1Cv8.cf', '/ConfigurationRepositoryN' , RepUserName, '/ConfigurationRepositoryP' , RepPassword,'/ConfigurationRepositoryF' , RepDir], shell=False)
except Exception as e:
print ("Create distribution file error: %s" % e)
return False
#update DemoDB
try:
subprocess.check_call([AppPath, 'DESIGNER', '/F', DemoDBDir , '/N', DemoDBUser, '/UpdateCfg', WorkingDir + '\\1Cv8.cf', '/UpdateDBCfg'], shell=False)
except Exception as e:
print "Update demo database error:" + e.message
#Open Demo DB
subprocess.call([AppPath, 'ENTERPRISE', '/F', DemoDBDir , '/N', DemoDBUser, '/UpdateCfg'], shell=False)
#dump DemoDB archive
try:
subprocess.check_call([AppPath, 'DESIGNER', '/F', DemoDBDir ,'/N', DemoDBUser, '/DumpIB', WorkingDir + '\\1Cv8.dt'])
except Exception as e:
print "Making dump demo database archive error:" + e.message
return False
DistrPackagePath = DistrDir + "\\" + nextReleaseDirName + "\\DistributionPackage.edf"
if update == False:
files = glob.iglob(os.path.join(DistrDir + "\\" + lastReleaseDirName, "*.pdf"))
for file in files:
if os.path.isfile(file):
shutil.copy2(file, DistrDir + "\\" + nextReleaseDirName)
files = glob.iglob(os.path.join(DistrDir + "\\" + lastReleaseDirName, "*.epf"))
for file in files:
if os.path.isfile(file):
shutil.copy2(file, DistrDir + "\\" + nextReleaseDirName)
shutil.copyfile(DistrDir + "\\" + lastReleaseDirName + "\\DistributionPackage.edf", DistrPackagePath)
f = open(DistrPackagePath,'r')
filedata = f.read()
f.close()
newdata = filedata.replace(lastReleaseDirName,nextReleaseDirName)
f = open(DistrPackagePath,'w')
f.write(newdata)
f.close()
#CreateDistributive
try:
subprocess.check_call([AppPath, 'DESIGNER', '/F', ConfDir , '/N', ConfUser, '/ConfigurationRepositoryN' , RepUserName, '/ConfigurationRepositoryP' , RepPassword,'/ConfigurationRepositoryF' , RepDir, '/CreateDistributive', SetupDir, '-File', DistrPackagePath,'-MakeSetup'], shell=False)
except Exception as e:
print "Create distributive error:" + e.message
return False
# commit changes into git-repository
if update:
commitMsg = 'update release ' + nextReleaseDirName
else:
commitMsg = 'release ' + nextReleaseDirName
try:
subprocess.check_call(['git', 'commit', '-m',commitMsg,SetupDir], shell=False)
except Exception as e:
print "Commit changes error:" + e.message
return False
return True
def FindLastReleaseDir():
dirs = os.walk( os.path.join(DistrDir,'.')).next()[1]
dirs.sort(reverse=True)
if dirs.count > 0:
return dirs[0]
return ""
class App(Frame):
def makeDistr(self):
if MakeDistr(self.lastReleaseDirName.get(),self.nextReleaseDirName.get(), False if self.cbstate.get()==0 else True) == True:
self.message["text"] = "Setup package was created."
self.message["fg"] = "green"
print("Setup package was created.")
else:
self.message["text"] = "Error!"
self.message["fg"] = "red"
print("Error!")
def cb(self):
if self.cbstate.get() == 0:
self.nextReleaseEdit['state'] = NORMAL
else:
self.nextReleaseEdit['state'] = DISABLED
def close_window(self):
root.destroy()
def createWidgets(self):
self.lastReleaseDirName = StringVar()
self.lastReleaseDirName.set(FindLastReleaseDir())
self.nextReleaseDirName = StringVar()
ver1, ver2, ver3, ver4 = str(self.lastReleaseDirName.get()).split('.')
self.nextReleaseDirName.set(ver1 + '.' + ver2 + '.' + ver3 + "." + str(int(ver4)+1))
self.parent.title("Setup package making")
# self.style = Style()
# self.style.theme_use("default")
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
frame1 = Frame(frame)
frame1.pack(fill=X, padx=5, pady=5)
Label(frame1, text="Last release:", width=10).pack(side=LEFT, padx=5)
self.lastReleaseEdit = Entry(frame1, textvariable = self.lastReleaseDirName)
self.lastReleaseEdit.pack(fill=X, padx=5, expand=True)
frame2 = Frame(frame)
frame2.pack(fill=X, padx=5, pady=5)
self.cbstate = IntVar()
cb = Checkbutton(frame2, text = "update current", command=self.cb, variable=self.cbstate)
cb.pack(fill=X, padx=5, expand=True);
frame3 = Frame(frame)
frame3.pack(fill=X, padx=5, pady=5)
Label(frame3, text="Next release:", width=10).pack(side=LEFT, padx=5)
self.nextReleaseEdit = Entry(frame3, textvariable = self.nextReleaseDirName)
self.nextReleaseEdit.pack(fill=X, padx=5, expand=True)
closeButton = Button(self, text="Close",command=self.close_window, width=10)
closeButton.pack(side=RIGHT, padx=5, pady=5)
okButton = Button(self, text="Run", width=16)
okButton.pack(side=RIGHT)
okButton["command"] = self.makeDistr
frame4 = Frame(frame)
frame4.pack(fill=X, padx=5, pady=5)
self.message = Label(frame4, text="")
self.message.pack(side=LEFT, padx=5)
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.parent = parent
self.pack()
self.createWidgets()
root = Tk()
root.geometry("300x170+300+300")
app = App(parent=root)
app.mainloop()
root.destroy()