/usr/lib/python2.7/dist-packages/variety/EarthDownloader.py is in variety 0.6.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (c) 2012, Peter Levi <peterlevi@peterlevi.com>
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import logging
import os
import subprocess
logger = logging.getLogger('variety')
from variety import Downloader
EARTH_IMAGE_URL = "https://static.die.net/earth/mercator/1600.jpg"
EARTH_ORIGIN_URL = "https://www.die.net/earth/"
EARTH_FILENAME = "earth.jpg"
class EarthDownloader(Downloader.Downloader):
def __init__(self, parent):
super(EarthDownloader, self).__init__(
parent, "earth", "Die.net", EARTH_ORIGIN_URL, is_refresher=True)
def convert_to_filename(self, url):
return "Earth"
def download_one(self):
logger.info(lambda: "Downloading world sunlight map from " + EARTH_ORIGIN_URL)
downloaded = self.save_locally(self.location, EARTH_IMAGE_URL, force_download=True, extra_metadata={'headline': 'World Sunlight Map'})
cropped = os.path.join(self.target_folder, EARTH_FILENAME)
subprocess.call(["convert", downloaded, "-gravity", "north", "-crop", "100%x95%", cropped])
for f in os.listdir(self.target_folder):
if f != EARTH_FILENAME and f.lower().endswith(".jpg"):
os.unlink(os.path.join(self.target_folder, f))
return cropped
|