Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locate, only_one #31

Open
mary-tsekhmistrenko opened this issue Dec 10, 2016 · 1 comment
Open

locate, only_one #31

mary-tsekhmistrenko opened this issue Dec 10, 2016 · 1 comment

Comments

@mary-tsekhmistrenko
Copy link
Collaborator

mary-tsekhmistrenko commented Dec 10, 2016

+def locate(root='.', target='info', only_one=False):
     """
     locates a subdirectory within a directory
     :param root:
@@ -382,9 +382,15 @@ def locate(root='.', target='info'):
     :return:
     """
     matches = []
+    found_one = False
     for root, dirnames, filenames in os.walk(root):
         for dirname in fnmatch.filter(dirnames, target):
             matches.append(os.path.join(root, dirname))
+            found_one = True
+            if only_one:
+                break
+        if found_one and only_one:
+            break

     return matches
@kasra-hosseini
Copy link
Owner

diff --git a/obspyDMT/utils/data_handler.py b/obspyDMT/utils/data_handler.py
index ff06d07..8ae4fc6 100644
--- a/obspyDMT/utils/data_handler.py
+++ b/obspyDMT/utils/data_handler.py
@@ -438,9 +438,11 @@ def arc_serial_parallel(stas_avail, event, input_dics, target_path,
     """
     print '%s -- event: %s' % (req_cli, target_path)
 
-    client_arclink = Client_arclink(user='[email protected]',
-                                    timeout=input_dics['arc_wave_timeout'])
-
+    client_arclink = Client_arclink(user='XXX', 
+                                    timeout=input_dics['arc_wave_timeout'], 
+                                    dcid_keys='XXX]', 
+                                    dcid_key_file='dcidpasswords.txt' )
+	
     if input_dics['req_parallel']:
         par_jobs = []
         st_counter = 0
diff --git a/obspyDMT/utils/event_handler.py b/obspyDMT/utils/event_handler.py
index 914c4c2..2438579 100644
--- a/obspyDMT/utils/event_handler.py
+++ b/obspyDMT/utils/event_handler.py
@@ -126,7 +126,7 @@ def read_info(input_dics):
     :param input_dics:
     :return:
     """
-    evs_info = locate(input_dics['datapath'], 'EVENTS-INFO')
+    evs_info = locate(input_dics['datapath'], 'EVENTS-INFO', only_one=True)
     if len(evs_info) == 0:
         return "no_local"
     if len(evs_info) > 1:
diff --git a/obspyDMT/utils/local_handler.py b/obspyDMT/utils/local_handler.py
index 8086fb3..1190113 100644
--- a/obspyDMT/utils/local_handler.py
+++ b/obspyDMT/utils/local_handler.py
@@ -49,7 +49,7 @@ def process_data(input_dics, event):
     :param event:
     :return:
     """
-    target_path = locate(input_dics['datapath'], event['event_id'])
+    target_path = locate(input_dics['datapath'], event['event_id'], search_depth=1)
 
     if len(target_path) == 0:
         return
diff --git a/obspyDMT/utils/utility_codes.py b/obspyDMT/utils/utility_codes.py
index dd7b579..9a5c9fb 100644
--- a/obspyDMT/utils/utility_codes.py
+++ b/obspyDMT/utils/utility_codes.py
@@ -374,7 +374,7 @@ def create_station_event(address):
 # ##################### locate ##########################################
 
 
-def locate(root='.', target='info'):
+def locate(root='.', target='info', search_depth=10, only_one=True):
     """
     locates a subdirectory within a directory
     :param root:
@@ -382,9 +382,19 @@ def locate(root='.', target='info'):
     :return:
     """
     matches = []
+    found_one = False
+    cur_depth = 0
     for root, dirnames, filenames in os.walk(root):
         for dirname in fnmatch.filter(dirnames, target):
             matches.append(os.path.join(root, dirname))
+            found_one = True
+            if only_one:
+                break
+        if found_one and only_one:
+            break
+        if cur_depth > search_depth:
+            break
+        cur_depth += 1
 
     return matches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants