122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# does the favicon exist
def available(url):
return os.path.exists(file(url))
# copy image from url into icons/ directory
def localcopy(url, download=False):
if url.startswith("http"):
fn = re.sub("[:/]", "_", url)
fn = conf.dir + "/icons/" + fn
if os.path.exists(fn):
return fn
elif download:
imgdata = ahttp.get(url, binary=1)
with open(fn, "wb") as f:
f.write(imgdata)
f.close()
if os.path.exists(fn):
return fn
else:
return url
|
|
|
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# does the favicon exist
def available(url):
return os.path.exists(file(url))
# copy image from url into icons/ directory
def localcopy(url, download=False):
if url and url.startswith("http"):
fn = re.sub("[:/]", "_", url)
fn = conf.dir + "/icons/" + fn
if os.path.exists(fn):
return fn
elif download:
imgdata = ahttp.get(url, binary=1, verify=False)
with open(fn, "wb") as f:
f.write(imgdata)
f.close()
if os.path.exists(fn):
return fn
else:
return url
|