Package PyFoam :: Package Applications :: Module PackCase
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.PackCase

 1  """ 
 2  Application-class that implements pyFoamPackCase.py 
 3  """ 
 4   
 5  from PyFoamApplication import PyFoamApplication 
 6   
 7  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 8   
 9  from os import path 
10   
11 -class PackCase(PyFoamApplication):
12 - def __init__(self,args=None):
13 description=""" 14 Packs a case into a tar-file copying the system, constant and 0-directories. 15 Excludes all .svn-direcotries and all files ending with ~ 16 """ 17 PyFoamApplication.__init__(self,args=args,description=description,usage="%prog <case>",interspersed=True,nr=1)
18
19 - def addOptions(self):
20 self.parser.add_option("--last", 21 action="store_true", 22 dest="last", 23 default=False, 24 help="Also add the last time-step") 25 self.parser.add_option("--pyfoam", 26 action="store_true", 27 dest="pyfoam", 28 default=False, 29 help="Add all files starting with PyFoam to the tarfile") 30 self.parser.add_option("--chemkin", 31 action="store_true", 32 dest="chemkin", 33 default=False, 34 help="Also add the Chemkin-directory") 35 self.parser.add_option("--add", 36 action="append", 37 dest="additional", 38 default=[], 39 help="Add all files and directories in the case directory that fit a glob-pattern to the tar (can be used more than once)") 40 self.parser.add_option("--exclude", 41 action="append", 42 dest="exclude", 43 default=[], 44 help="Exclude all files and directories that fit this glob pattern from being added, no matter at level (can be used more than once)") 45 self.parser.add_option("--tarname", 46 action="store", 47 dest="tarname", 48 default=None, 49 help='Name of the tarfile. If unset the name of the case plus ".tgz" will be used')
50
51 - def run(self):
52 sName=self.parser.getArgs()[0] 53 if sName[-1]==path.sep: 54 sName=sName[:-1] 55 56 if self.parser.getOptions().tarname!=None: 57 dName=self.parser.getOptions().tarname 58 else: 59 dName=sName+".tgz" 60 if self.parser.getOptions().pyfoam: 61 self.parser.getOptions().additional.append("PyFoam*") 62 63 sol=SolutionDirectory(sName,archive=None,paraviewLink=False) 64 65 if self.parser.getOptions().chemkin: 66 sol.addToClone("chemkin") 67 68 sol.packCase(dName, 69 last=self.parser.getOptions().last, 70 additional=self.parser.getOptions().additional, 71 exclude=self.parser.getOptions().exclude)
72