Commit 5ecf76b1 authored by michitaro's avatar michitaro
Browse files

hotfix for problem that tar.next() raises StreamError

parent 0c49f85a
......@@ -25,9 +25,9 @@ import os, os.path
import contextlib
import logging ; logging.basicConfig(level=logging.INFO)
try:
import pyfits
import pyfits # type: ignore
except:
import astropy.io.fits as pyfits
import astropy.io.fits as pyfits # type: ignore
import numpy
import PIL.Image
......@@ -43,7 +43,7 @@ def main():
parser.add_argument('input', type=argparse.FileType('r'))
args = parser.parse_args()
password = getpass.getpass('Password for public-release: ')
password = os.environ.get('PASSWORD') or getpass.getpass('Password for public-release: ')
checkPassword(args.user, password)
coords, outs = loadCoords(args.input)
......@@ -67,7 +67,7 @@ API = 'https://hsc-release.mtk.nao.ac.jp/das_cutout/pdr3/cgi-bin/cutout'
def loadCoords(input):
import re
comment = re.compile('\s*(?:$|#)')
comment = re.compile(r'\s*(?:$|#)')
num = 1
coords = []
outs = []
......@@ -122,7 +122,8 @@ def rgbBundle(files):
dst = locals()[ch]
copyFileObj(fileObj, dst)
rgb[ch] = dst.name
yield objNum, rgb
if len(rgb) > 0:
yield objNum, rgb
......@@ -155,7 +156,13 @@ def queryTar(user, password, requestFile):
with tarfile.open(fileobj=pipe.stdout, mode='r|*') as tar:
while True:
info = tar.next()
try:
info = tar.next()
except tarfile.StreamError as e:
if tar.offset == 0:
break
else:
raise
if info is None: break
logging.info('extracting {}...'.format(info.name))
f = tar.extractfile(info)
......
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