Commit c66fb6d8 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

path bug

parent 0fe65969
......@@ -27,11 +27,14 @@ def ingest():
elif 'sky' in filename.lower():
file_type = 'sky'
file_path = file_full_path.replace(root_dir, '')
if file_path.index("/") == 0:
file_path = file_path[1:]
if file_type in ['obs']:
fitsApi.import2db(file_path = file_full_path.replace(root_dir, '')[1:])
fitsApi.import2db(file_path = file_path)
print("%s [type:%s] imported" %(file_full_path, file_type))
if file_type in ['flat', 'bias', 'arc','hgar', 'sky']:
refApi.import2db(file_path = file_full_path.replace(root_dir, '')[1:])
refApi.import2db(file_path = file_path)
print("%s [type:%s] imported" %(file_full_path, file_type))
return paths
......@@ -27,10 +27,6 @@ class FitsApi(object):
log.info("using [%s] as root directory", self.root_dir)
if not os.path.exists(os.path.join(self.root_dir, "fits")):
os.mkdir(os.path.join(self.root_dir, "fits"))
if not os.path.exists(os.path.join(self.root_dir, "refs")):
os.mkdir(os.path.join(self.root_dir, "refs"))
if not os.path.exists(os.path.join(self.root_dir, "results")):
os.mkdir(os.path.join(self.root_dir, "results"))
def find(self, **kwargs):
'''
......@@ -216,4 +212,8 @@ class FitsApi(object):
new_file_path = os.path.join(new_file_dir, file_basename)
shutil.copyfile(file_path, new_file_path)
self.import2db(file_path = new_file_path.replace(self.root_dir, '')[1:])
\ No newline at end of file
file_path = new_file_path.replace(self.root_dir, '')
if file_path.index("/") == 0:
file_path = file_path[1:]
self.import2db(file_path = file_path)
\ No newline at end of file
......@@ -208,7 +208,11 @@ class RefFitsApi(object):
new_file_path = os.path.join(new_file_dir, file_basename)
shutil.copyfile(file_path, new_file_path)
self.import2db(file_path = new_file_path.replace(self.root_dir, '')[1:])
file_path = new_file_path.replace(self.root_dir, '')
if file_path.index("/") == 0:
file_path = file_path[1:]
self.import2db(file_path = file_path)
def associate_raw(self, **kwargs):
......
......@@ -114,10 +114,14 @@ class Result0Api(object):
new_file_path = os.path.join(new_file_dir, file_basename)
shutil.copyfile(file_path, new_file_path)
file_path = new_file_path.replace(self.root_dir, '')
if file_path.index("/") == 0:
file_path = file_path[1:]
self.db.execute(
'INSERT INTO ifs_result_0 (filename, file_path, raw_id, proc_type, create_time) \
VALUES(?,?,?,?,?)',
(file_basename, new_file_path.replace(self.root_dir, '')[1:], raw_id, proc_type, format_time_ms(time.time()))
(file_basename, file_path, raw_id, proc_type, format_time_ms(time.time()))
)
self.db.end()
......
......@@ -110,10 +110,14 @@ class Result1Api(object):
shutil.copyfile(file_path, new_file_path)
file_path = new_file_path.replace(self.root_dir, '')
if file_path.index("/") == 0:
file_path = file_path[1:]
self.db.execute(
'INSERT INTO ifs_result_1 (filename, file_path, proc_type, create_time) \
VALUES(?,?,?,?)',
(file_basename, new_file_path.replace(self.root_dir, '')[1:], proc_type, format_time_ms(time.time()),)
(file_basename, file_path, proc_type, format_time_ms(time.time()),)
)
self.db.end()
result1_id = 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment