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

datetime bug

parent 5f4964fe
...@@ -210,7 +210,7 @@ class FitsApi(object): ...@@ -210,7 +210,7 @@ class FitsApi(object):
new_file_dir = create_dir(os.path.join(self.root_dir, "fits"), new_file_dir = create_dir(os.path.join(self.root_dir, "fits"),
self.sub_system, self.sub_system,
"/".join([str(datetime.datetime.now().year),"%02d"%(datetime.datetime.now().month),"%02d"%(datetime.datetime.now().day)])) "/".join([str(datetime.now().year),"%02d"%(datetime.now().month),"%02d"%(datetime.now().day)]))
file_basename = os.path.basename(file_path) file_basename = os.path.basename(file_path)
new_file_path = os.path.join(new_file_dir, file_basename) new_file_path = os.path.join(new_file_dir, file_basename)
......
...@@ -201,7 +201,7 @@ class RefFitsApi(object): ...@@ -201,7 +201,7 @@ class RefFitsApi(object):
new_file_dir = create_dir(os.path.join(self.root_dir, "refs"), new_file_dir = create_dir(os.path.join(self.root_dir, "refs"),
self.sub_system, self.sub_system,
"/".join([str(datetime.datetime.now().year),"%02d"%(datetime.datetime.now().month),"%02d"%(datetime.datetime.now().day)])) "/".join([str(datetime.now().year),"%02d"%(datetime.now().month),"%02d"%(datetime.now().day)]))
file_basename = os.path.basename(file_path) file_basename = os.path.basename(file_path)
......
...@@ -107,7 +107,7 @@ class Result0Api(object): ...@@ -107,7 +107,7 @@ class Result0Api(object):
new_file_dir = create_dir(os.path.join(self.root_dir, "results0"), new_file_dir = create_dir(os.path.join(self.root_dir, "results0"),
self.sub_system, self.sub_system,
"/".join([str(datetime.datetime.now().year),"%02d"%(datetime.datetime.now().month),"%02d"%(datetime.datetime.now().day)])) "/".join([str(datetime.now().year),"%02d"%(datetime.now().month),"%02d"%(datetime.now().day)]))
file_basename = os.path.basename(file_path) file_basename = os.path.basename(file_path)
......
...@@ -103,7 +103,7 @@ class Result1Api(object): ...@@ -103,7 +103,7 @@ class Result1Api(object):
new_file_dir = create_dir(os.path.join(self.root_dir, "results1"), new_file_dir = create_dir(os.path.join(self.root_dir, "results1"),
self.sub_system, self.sub_system,
"/".join([str(datetime.datetime.now().year),"%02d"%(datetime.datetime.now().month),"%02d"%(datetime.datetime.now().day)])) "/".join([str(datetime.now().year),"%02d"%(datetime.now().month),"%02d"%(datetime.now().day)]))
file_basename = os.path.basename(file_path) file_basename = os.path.basename(file_path)
new_file_path = os.path.join(new_file_dir, file_basename) new_file_path = os.path.join(new_file_dir, file_basename)
......
...@@ -9,25 +9,25 @@ class IFSResult0TestCase(unittest.TestCase): ...@@ -9,25 +9,25 @@ class IFSResult0TestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.api = Result0Api() self.api = Result0Api()
def test_find(self): # def test_find(self):
recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') # recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits')
print('find:', recs) # print('find:', recs)
assert len(recs) == 1 # assert len(recs) == 1
recs = self.api.find() # recs = self.api.find()
print('find:', recs) # print('find:', recs)
assert len(recs) > 1 # assert len(recs) > 1
def test_read(self): # def test_read(self):
recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits') # recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits')
print("The full path: ", os.path.join(self.api.root_dir, recs[0]['file_path'])) # print("The full path: ", os.path.join(self.api.root_dir, recs[0]['file_path']))
file_segments = self.api.read(file_path=recs[0]['file_path']) # file_segments = self.api.read(file_path=recs[0]['file_path'])
file_bytes = b''.join(file_segments) # file_bytes = b''.join(file_segments)
hdul = fits.HDUList.fromstring(file_bytes) # hdul = fits.HDUList.fromstring(file_bytes)
print(hdul.info()) # print(hdul.info())
hdr = hdul[0].header # hdr = hdul[0].header
print(repr(hdr)) # print(repr(hdr))
def test_write(self): def test_write(self):
self.api.write(raw_id = 1, self.api.write(raw_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