Created
April 17, 2015 10:03
-
-
Save elleryq/e0fd7646525c25ec48fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import datetime | |
| from threading import Thread | |
| from Queue import Queue, Empty | |
| import sys | |
| class mseed2sac(): | |
| def __init__(self): | |
| self.start_time = datetime.datetime.now() | |
| #self.path = 'd:\\test\\mseed\\2015\\103' | |
| self.path = "/tmp" | |
| self.main() | |
| self.end_time = datetime.datetime.now() | |
| print "start time", self.start_time | |
| print "end time", self.end_time | |
| def DO_mseed2sac(self,i,q): | |
| while True: | |
| print "#{0} q.empty()={1}".format(i, q.empty()) | |
| if q.empty(): | |
| #sys.exit() | |
| break | |
| try: | |
| cmd = q.get(False) | |
| except Empty: | |
| break | |
| #print cmd | |
| def main(self): | |
| result = os.listdir(self.path) | |
| num_threads = 10 | |
| q = Queue() | |
| print "------- starting DO_mseed2sac -------" | |
| for i in result: | |
| tmp = i.split("-") | |
| if len(tmp) == 3 and len(tmp[2]) > 2: | |
| cmd = 'mseed2sac %s'%( | |
| os.path.join(self.path, tmp[2])) | |
| q.put(cmd) | |
| for i in range(num_threads): | |
| worker = Thread(target=self.DO_mseed2sac, args=(i, q)) | |
| worker.setDaemon(True) | |
| worker.start() | |
| worker.join() | |
| if __name__=='__main__': | |
| mseed2sac() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment