X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=otp_imgswap.py;h=5bfad9762ae60072fdf4777ed442e8019f0eb27c;hb=87cd975d6106b94efe25f003d937722ae3afaad0;hp=0a2d72b7e5680b0419584298ec558ac5ba916265;hpb=9ff559dc6df0bb275afc2379ad24043d66dc3a20;p=otptools%2Fotptools.git diff --git a/otp_imgswap.py b/otp_imgswap.py index 0a2d72b..5bfad97 100755 --- a/otp_imgswap.py +++ b/otp_imgswap.py @@ -53,10 +53,12 @@ for line in in_f: if match: tagstr = match.group(0) path = match.group(1) - if os.path.isfile(path): - md5 = get_md5(path) + try: + if os.path.isfile(path): + md5 = get_md5(path) # tag has alt ? - slashtag = """""" % (md5,) - line = line.replace(tagstr, slashtag) - + slashtag = """""" % (md5,) + line = line.replace(tagstr, slashtag) + except UnicodeEncodeError: + print >> sys.stderr, "invalid path: %s (%s)" % (path.encode("utf-8"), line.strip().encode("utf-8")) print >> out_f, line,