[059924]: mat2doc / publish.py Maximize Restore History

Download this file

publish.py    204 lines (148 with data), 6.4 kB

  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
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/python
import sys,os
cwd=os.getcwd()+os.sep
tbwww='/home/peter/nw/ltfatwww'
# ------- do not edit below this line ----------
# Import the localconf file, it should be placed in the same directory
# as this function is called from.
sys.path.append(cwd)
import localconf
sys.path.append(localconf.mat2docdir)
import mat2doc
import printdoc
# Safely create directories if they are missing
printdoc.safe_mkdir(localconf.outputdir)
printdoc.safe_mkdir(localconf.tmpdir)
# This is run if the file is called from the command line
project=sys.argv[1]
todo=sys.argv[2]
redomode='auto'
if len(sys.argv)>3:
redomode=sys.argv[3]
projectdir=localconf.projects[project]
host=localconf.webserver[project]
remotedir=localconf.remotedir[project]
projectname=project # For mat2docconf
outputdir=localconf.outputdir # For mat2docconf
#sys.path.append(projectdir+'mat2doc')
#from mat2docconf import *
conffile=projectdir+'mat2doc/mat2docconf.py'
newlocals=locals()
execfile(conffile,globals(),newlocals)
filesdir=localconf.outputdir+project+'-files'+os.sep
printdoc.safe_mkdir(filesdir)
def createcompressedfile(srcdir,fname,target):
# The following targets are supported:
# unix - Unix lineendings, UTF-8 encoding and gzip compression
# win - Windows lineendings, 8859 enconding and zip compression
# mac - Unix lineendings, 8859 encoding and zip compression
tmpworkdir=localconf.tmpdir+project
fname=filesdir+fname
srcdir=localconf.outputdir+srcdir+os.sep
printdoc.safe_mkdir(tmpworkdir)
printdoc.rmrf(tmpworkdir)
# Create zip and tgz archives. In order to get the right path in
# the compressed files, copy the source to the temporary directory
# with the project
printdoc.rmrf(tmpworkdir)
os.system('cp -R '+srcdir+'* '+tmpworkdir)
if target=='unix':
os.system('cd '+localconf.tmpdir+'; tar zcvf '+fname+'.tgz '+project)
if target=='win':
os.system('rm '+fname+'.zip')
printdoc.unix2dos(tmpworkdir)
printdoc.convertencoding(tmpworkdir,'ISO-8859-1')
os.system('cd '+localconf.tmpdir+'; zip -r '+fname+'.zip '+project)
if target=='mac':
os.system('rm '+fname+'.zip')
printdoc.convertencoding(tmpworkdir,'ISO-8859-1')
os.system('cd '+localconf.tmpdir+'; zip -r '+fname+'.zip '+project)
def createbinaryfile(filename,ext,target):
tmpworkdir=localconf.outputdir+project+'-mat'
bdir=localconf.outputdir+project+'-'+ext
printdoc.safe_mkdir(bdir)
printdoc.rmrf(bdir)
s='cp -r '+tmpworkdir+'/* '+bdir
os.system(s)
s='cp -r '+localconf.outputdir+project+'-'+ext+'-addon/* '+bdir
os.system(s)
createcompressedfile(project+'-'+ext,project+'-'+versionstring+'-'+ext,target)
def runcommand(todo,redomode='auto'):
# When editing these commands, some variables are already defined
#
# versionstring - This is the string from mat2docconf
# project - This is the name of the project from calling publish.py
print 'PUBLISH '+todo+' '+redomode
# Simple commands to make the others easier to write
if todo=='svnmat':
pass
if todo=='gitstagemat':
printdoc.git_stageexport_mat(project)
os.system('mat2doc mat '+projectdir)
if todo=='gitrepomat':
printdoc.git_repoexport_mat(project)
printdoc.printdoc(project,'mat')
# Release for other developers to download
if 'develmat' in todo:
runcommand('gitstagemat')
createcompressedfile(project+'-mat',project+'-devel-'+printdoc.datesuffix(),'unix')
createcompressedfile(project+'-mat',project+'-devel-'+printdoc.datesuffix(),'win')
# Release for users to download
if 'releasemat' in todo:
runcommand('gitrepomat')
matdir=localconf.outputdir+project+'-mat'+os.sep
# Remove unwanted files
os.system('rm -rf '+matdir+'mat2doc')
os.system('rm -rf '+matdir+'testing')
os.system('rm -rf '+matdir+'reference')
os.system('rm -rf '+matdir+'timing')
createcompressedfile(project+'-mat',project+'-'+versionstring,'unix')
createcompressedfile(project+'-mat',project+'-'+versionstring,'win')
if 'tex'==todo:
printdoc.printdoc(project,'tex',redomode)
if 'texmake'==todo:
s=localconf.outputdir+project+'-tex/'
os.system('cp '+projectdir+'mat2doc/tex/* '+s)
os.system('cd '+s+'; make')
printdoc.printdoc(project,'tex',redomode)
if 'texupload'==todo:
texdir=localconf.outputdir+project+'-tex'+os.sep
s='rsync -av '+texdir+'ltfat.pdf '+host+':'+remotedir
os.system(s)
if todo=='php':
phpdir=localconf.outputdir+project+'-php'+os.sep
os.system('mat2doc php '+projectdir)
s='rsync -av '+phpdir+' '+host+':'+remotedir
os.system(s)
if todo=='phplocal' in todo:
printdoc.printdoc(project,'phplocal',redomode)
if todo=='fullrelease':
runcommand('releasemat',redomode)
runcommand('binary')
runcommand('php',redomode)
runcommand('tex',redomode)
runcommand('texupload')
if 'stagewww'==todo:
www='/home/project-web/ltfat/htdocs/'
publishwww=localconf.outputdir+'ltfatwww/'
printdoc.git_stageexport(tbwww,publishwww)
os.system('rsync -av '+publishwww+' '+host+':'+www);
if 'releasewww'==todo:
www='/home/project-web/ltfat/htdocs/'
publishwww=localconf.outputdir+'ltfatwww/'
printdoc.git_repoexport(tbwww,'master','ltfatwww',localconf.outputdir)
os.system('rsync -av '+publishwww+' '+host+':'+www);
if 'binary'==todo:
# You must run this command right after the "releasemat" or
# "develmat" commands as this will create a correct "-mat"
# directory
createbinaryfile(project+'-'+versionstring,'win64','win')
createbinaryfile(project+'-'+versionstring,'mac','mac')
#if 'upload' in todo:
# ddir=localconf.outputdir+'ltfat_sourceforge/ltfat/'
# os.system('rsync -av '+ddir+
# ' soender,ltfat@frs.sourceforge.net:/home/frs/project/l/lt/ltfat/ltfat/')
if todo=='verify':
printdoc.printdoc(project,'verify',redomode)
# Excute runcommand, this is where the main stuff happens
runcommand(todo,redomode)