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, 18 args=args, 19 description=description, 20 usage="%prog <case>", 21 interspersed=True, 22 changeVersion=False, 23 nr=1)
24
25 - def addOptions(self):
26 self.parser.add_option("--last", 27 action="store_true", 28 dest="last", 29 default=False, 30 help="Also add the last time-step") 31 self.parser.add_option("--pyfoam", 32 action="store_true", 33 dest="pyfoam", 34 default=False, 35 help="Add all files starting with PyFoam to the tarfile") 36 self.parser.add_option("--chemkin", 37 action="store_true", 38 dest="chemkin", 39 default=False, 40 help="Also add the Chemkin-directory") 41 self.parser.add_option("--add", 42 action="append", 43 dest="additional", 44 default=[], 45 help="Add all files and directories in the case directory that fit a glob-pattern to the tar (can be used more than once)") 46 self.parser.add_option("--exclude", 47 action="append", 48 dest="exclude", 49 default=[], 50 help="Exclude all files and directories that fit this glob pattern from being added, no matter at level (can be used more than once)") 51 self.parser.add_option("--tarname", 52 action="store", 53 dest="tarname", 54 default=None, 55 help='Name of the tarfile. If unset the name of the case plus ".tgz" will be used')
56
57 - def run(self):
58 sName=self.parser.getArgs()[0] 59 if sName[-1]==path.sep: 60 sName=sName[:-1] 61 62 if self.parser.getOptions().tarname!=None: 63 dName=self.parser.getOptions().tarname 64 else: 65 dName=sName+".tgz" 66 if self.parser.getOptions().pyfoam: 67 self.parser.getOptions().additional.append("PyFoam*") 68 69 sol=SolutionDirectory(sName,archive=None,paraviewLink=False) 70 71 if self.parser.getOptions().chemkin: 72 sol.addToClone("chemkin") 73 74 sol.packCase(dName, 75 last=self.parser.getOptions().last, 76 additional=self.parser.getOptions().additional, 77 exclude=self.parser.getOptions().exclude)
78