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