File: mrtg.py

package info (click to toggle)
lcd4linux 0.11.0~svn1200-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,364 kB
  • ctags: 3,514
  • sloc: ansic: 36,524; sh: 4,479; makefile: 208; python: 83; perl: 33
file content (21 lines) | stat: -rw-r--r-- 507 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import urllib
import shutil

download_path = "/tmp/"

def saveimage(imageurl):
	filename = imageurl.split('/')[-1]
	tmpname = filename + ".tmp"
	try:
		urllib.urlretrieve(imageurl, download_path + tmpname)
	except IOError:
		return "Error downloading file"
	else:
		shutil.move(download_path + tmpname, download_path + filename)
		return download_path + filename


#saveimage("http://www.switch.ch/network/operation/statistics/geant2-day.png")
#saveimage("http://192.168.12.113/mrtg/127.0.0.1_2-day.png")