started implementation of running of external programs (work in progress, pending until release of picking window)
This commit is contained in:
parent
6b14c452e2
commit
ff52ec5410
@ -3,6 +3,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import pwd
|
import pwd
|
||||||
import re
|
import re
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -10,6 +11,27 @@ import numpy as np
|
|||||||
from obspy.core import UTCDateTime
|
from obspy.core import UTCDateTime
|
||||||
import obspy.core.event as ope
|
import obspy.core.event as ope
|
||||||
|
|
||||||
|
def runProgram(cmd, parameter=None):
|
||||||
|
"""
|
||||||
|
run an external program specified by cmd with parameters input returning the
|
||||||
|
stdout output
|
||||||
|
|
||||||
|
:param cmd: name of the command to run
|
||||||
|
:type cmd: str
|
||||||
|
:param parameter: filename of parameter file or parameter string
|
||||||
|
:type parameter: str
|
||||||
|
:return: stdout output
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
if parameter:
|
||||||
|
cmd.strip()
|
||||||
|
cmd += ' %s 2>&1' % parameter
|
||||||
|
|
||||||
|
output = subprocess.check_output('{} | tee /dev/stderr'.format(cmd),
|
||||||
|
shell = True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fnConstructor(s):
|
def fnConstructor(s):
|
||||||
if type(s) is str:
|
if type(s) is str:
|
||||||
|
Loading…
Reference in New Issue
Block a user