コード例 #1
0
ファイル: resource.py プロジェクト: vonseg/antelope_contrib
    def _extract_request(self, request):
        
        net = request.args.get('net', [None])
        sta = request.args.get('sta', [None])[0]
        chan_args = request.args.get('chan', []) 
        time_window = float(request.args.get('tw', [0])[0])
        time_start = float(request.args.get('ts', [-1])[0])
        time_end = float(request.args.get('te', [-1])[0])
        availability = request.args.get('availability', [False])[0]
        canvas_size = request.args.get('canvas_size', [config.canvas_size_default])[0] 

        chans = list(set([chan.upper() for chan in chan_args]))
        if not chans:
            chans = list(config.default_chans)
        chans.sort()

	if config.verbose:
	    print "Received request for:"
	    print "\tnet:\t%s" % net
	    print "\tsta:\t%s" % sta
	    print "\tchans:\t%s" % str(chans)
	    print "\ttime_window:\t%s" % stock.strtdelta(time_window)
	    print "\ttime_start:\t%s" % stock.strtime(time_start)
	    print "\ttime_end:\t%s" % stock.strtime(time_end)
	    print "\tavailability:\t%s" % str(availability)
	    print "\tcanvas_size:\t%d" % canvas_size

	return net, sta, chans, time_window, time_start, time_end, availability, canvas_size
コード例 #2
0
def logmsg(message, forced=False):

    if message is None: message = ''

    from __main__ import verbose
    global globalLog

    if not forced and not verbose: return

    if not isinstance(message, basestring):
        print type(message)
        message = '\n%s\n' % pprint.pformat(message, indent=4)

    #globalLog = '%s\n%s %s' % (globalLog,stock.strtime(stock.now()), message)
    globalLog += '%s %s\n' % (stock.strtime(stock.now()), message)
    print '%s %s' % (stock.strtime(stock.now()), message)
コード例 #3
0
ファイル: __init__.py プロジェクト: geoffdavis/anfsrc
    def run(self):
        """Run second_moment App."""

        # Create any necessary folders.
        self._setup_folders()

        # set path of matlab script
        sys.path.append(self.matlab_code_path)
        self.matlab_code = self.matlab_code_path + "/" + "run_second_moment.m"

        # -- Set matlab info
        self.logger.info("Start: %s %s" %
                         ("second_moment", stock.strtime(stock.now())))
        self.logger.info("Start: configuration parameter file %s" %
                         self.options.pf)
        self.logger.info(" - Xvfb path: %s" % self.xvfb_path)
        self.logger.info(" - Matlab path: %s" % self.matlab_path)
        self.logger.info(" - Matlab flags: %s" % self.matlab_flags)

        # Set virtual display if needed
        if not self.options.window and self.xvfb_path:
            result = self._setup_xvfb()
            if not result:
                logger.error("Xvfb setup failed. Can't continue.")
                return -1

        self._run_matlab()

        # -- Kill virtual display if needed -- #
        if not self.options.window:
            self._kill_xvfb()
コード例 #4
0
ファイル: util.py プロジェクト: geoffdavis/anfsrc
    def get_origin(self, orid):
        """Get origin info from database."""
        steps = ["dbopen origin"]
        steps.extend(["dbsubset orid==%s" % orid])

        self.logger.debug("Database query for origin info:")
        self.logger.debug(", ".join(steps))
        dbview = self.db.process(steps)

        if not dbview.record_count:
            self.logger.error("No origin after subset for orid [%s]" %
                              self.orid)

        for temp in dbview.iter_record():
            (orid, time, lat, lon, depth) = temp.getv("orid", "time", "lat",
                                                      "lon", "depth")

            self.logger.info("orid=%s" % orid)
            self.logger.info("time:%s (%s,%s)" % (time, lat, lon))

            self.orid = orid
            self.depth = depth
            self.strtime = stock.strtime(time)
            self.strdate = stock.strdate(time)
            self.time = time
            self.lat = lat
            self.lon = lon
コード例 #5
0
def logmsg(message, forced=False):

    if message is None:
        message = ""

    from __main__ import verbose

    global globalLog

    if not forced and not verbose:
        return

    if not isinstance(message, string_types):
        message = "\n%s\n" % pprint.pformat(message, indent=4)

    globalLog += "%s %s\n" % (stock.strtime(stock.now()), message)
    print("%s %s" % (stock.strtime(stock.now()), message))
コード例 #6
0
def per_sta_query(flickr, staname, tags, myid, archive, url_path):
    """Create a subprocess
    for the selected station

    """

    logmsg("Start %s at %s" % (staname, stock.strtime(stock.now())))

    try:
        flickr_photo_retrieval(flickr, staname, tags, myid, archive, url_path)
    except Exception as e:
        logerror("%s execution failed: %s" % (staname, e))
コード例 #7
0
def per_sta_query(flickr, staname, tags, myid, archive, url_path):
    """Create a subprocess
    for the selected station

    """


    logmsg("Start %s at %s" % (staname,stock.strtime(stock.now())) )

    try:
        flickr_photo_retrieval(flickr, staname, tags, myid, archive, url_path)
    except Exception, e:
        logerror( "%s execution failed: %s" % (staname,e) )
コード例 #8
0
 def _toTime (self, value):
     return stock.strtime(value)
コード例 #9
0
ファイル: dlmon.py プロジェクト: geoffdavis/anfsrc
 def _toTime(self, value):
     return stock.strtime(value)
コード例 #10
0
ファイル: __init__.py プロジェクト: geoffdavis/anfsrc
    def _run_matlab(self):
        """Run Matlab code."""

        cmd = """%s -r \"matlab_code='%s';
verbose='%s';
debug='%s';
debug_plot='%s';
interactive='%s';
no_figure='%s';
image_dir='%s';
temp_dir='%s';
db='%s';
orid=%d;
egf=%s;
vel_model='%s';
reject='%s';
select='%s';
filter='%s';
tw='%s';
misfit_criteria=%.2f;
loc_margin=%.4f;
dep_margin=%.2f;
time_margin=%.1f;
LOADDATAFILE=%d;
DOMEAS=%d;
DOINVERSION=%d;
DOJACKKNIFE=%d;
azband=%d;
DOBOOTSTRAP=%d;
NB=%d;
bconf=%.2f;
NITER=%d;
TESTFAULT=%d;
auto_arrival='%s';
fault='%s';
\" < '%s'""" % (
            self.matlab_path,
            self.matlab_code_path,
            self.options.verbose,
            self.options.debug,
            self.options.debug_plot,
            self.options.interactive,
            self.options.no_figure,
            self.image_dir,
            self.temp_dir,
            self.database,
            int(self.orid),
            self.options.egf,
            self.model,
            self.options.reject,
            self.options.select,
            self.options.filter,
            self.options.tw,
            self.stf_duration_criteria,
            self.loc_margin,
            self.dep_margin,
            self.time_margin,
            self.loaddatafile,
            self.domeas,
            self.doinversion,
            self.dojackknife,
            self.azband,
            self.dobootstrap,
            self.nb,
            self.bconf,
            self.niter,
            self.testfault,
            self.auto_arrival,
            self.options.fault,
            self.matlab_code,
        )

        self.logger.info(" - Run Matlab script:")
        self.logger.info("   %s " % cmd)

        try:
            mcmd = execute(cmd)
        except Exception:
            self.logger.exception('Problem with command: "' + cmd +
                                  '". Result: ' + mcmd)

        if self.options.verbose:
            self.logger.info("Done: %s %s" %
                             ("second_moment", stock.strtime(stock.now())))