I am trying to use bash functions inside my Pyro script so that I can locate a specific directory and Then send a given file inside the directory. The catch is that I have only a part of the directory name, so I need to get the rest of the directory name to use the discovery of the remaining function (names are unique and only one folder will return)
Code I have so far as follows:
def get_tag (part_of_foldername): import subprocessing import OS p1 = subprocess. Popin (["Find", "/ path / copy / directory", "-maxappa", "1", "-name", "% s. *"% Part_of_foldname, "-type", "d"], stdout = Subprocess.PIPE) directory = p1.communicate () [0] .strip ('\ N') os.chdir (directory) p2 = subprocess.Popen (["grep", "STUFF_", ".hgtags"], Stdout = subprocess.PIPE) tag = p2.comminucate () [0] strip ('\ n') return tag What's really strange here is this code works when you Enter in the line interactive, but when it is run through a script when you enter the script file interti In the import and call function, but it will also work when called by the main function. The traceback I get from running the script directly:
traceback (most recent call final): file "./integration.py", line 64, and it has been called in such a main function:
block_ dict [block] [0] == '0': Tag = get_tag (folder) with the "Folder" as already defined as string.
Please note that we use Python 2.6, so I can not use it unfortunately module check_output unfortunately.
Have you tried to conflict with finding the module?
import glob glob.glob ("/ path / to / directory / * / SomeDir / path / *") You can see ** using:
glob.glob ("/ path / ** / somedir / path / *") and / Path / from / your / something / path / file
No comments:
Post a Comment