Skip to content

Commit

Permalink
- added a delay to the test service
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Nov 15, 2018
1 parent 40299ef commit 26f892a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/wpsremote/xmpp_data/configs/myservice/code/test.py
Expand Up @@ -8,14 +8,15 @@
import logging.config
import logging
import argparse
import sys
import sys
import thread
import traceback
import logging
import sys
import os
import uuid
import zipfile
import time

# constants
#id = os.urandom(10)
Expand All @@ -39,6 +40,10 @@ def run(self):
#fullCmd = ' '.join([gdalContour, cmd, self.youCanQuoteMe(src), self.youCanQuoteMe(dst), interval, self.args.interval])
fullCmd = ' '.join([gdalContour, cmd, src, trg, interval, self.args.interval])
self.logger.debug("Running command > " + fullCmd)

self.logger.info("going to sleep again...");
time.sleep(30) # Delays for 30 seconds. You can also use a float value.

proc=subprocess.Popen(fullCmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
for line in proc.stdout:
self.logger.info(line)
Expand All @@ -47,19 +52,23 @@ def run(self):
proc.communicate()
ret = proc.returncode

self.logger.info("...waking up and going to sleep again...");
time.sleep(30) # Delays for 30 seconds. You can also use a float value.

if (ret == 0):
# zipf = zipfile.ZipFile(self.args.workdir+'/contour.zip', 'w')
# self.zipdir(self.args.workdir+'/', zipf)
output_dir = '%s/../../../output/%s' % (os.path.dirname(os.path.abspath(__file__)), self.args.execution_id)
zipf = zipfile.ZipFile(output_dir+'/contour.zip', 'w')
self.zipdir(output_dir+'/', zipf)
zipf.close()

self.logger.info("ProgressInfo:100%")
else:
self.logger.critical("Error occurred during processing.")

return ret

# see note below
def youCanQuoteMe(self, item):
return "\"" + item + "\""
Expand All @@ -80,7 +89,6 @@ def create_logger(self, logger_config_file):
self.logger.debug("Logger initialized with file " + str(logger_config_file))

if __name__ == '__main__':

parser = argparse.ArgumentParser()
parser.add_argument("-i", "--interval", nargs='?', default="10", help="Elevation interval between contours.")
parser.add_argument("-w", "--workdir", nargs='?', default="", help="Remote process sandbox working directory.")
Expand Down

0 comments on commit 26f892a

Please sign in to comment.