Ejemplo n.º 1
0
    def run(self):
        ''' main function '''
        ''' get background picture from momentumdash.com '''

        print("Updating  infinity new tab image...")

        success = 0
        #ljx
        print("download...")
        while success == 0:
            index = random.randint(1000, 20000)
            filename = "/home/ljx/Pictures/infinity/" + str(index) + ".jpg"
            self.get_bg_picture(index)
            r = os.system("cat " + filename + " |grep error")
            if r != 0:
                success = 1
                break
            print("failed,again...")
            os.system("rm " + filename)

        #xjl

        print("\nSaving to '%s'..." % (filename))
        ''' set background picture as wallpaper '''
        ''' scaled, wallpaper, stretched, spanned '''
        if not set_background(filename, "stretched"):
            exit("Your desktop environment '{}' is not supported.".format(
                get_desktop_environment()))

        print("Done!")
Ejemplo n.º 2
0
def main():
    '''
    main function
    '''

    global counter
    ''' check if setting data is correct or not '''
    if auto_offset and hour_offset:
        exit(
            "You can not set `auto_offset` to True and `hour_offset` to a value that is different than zero."
        )
    elif hour_offset < 0:
        exit(
            "`hour_offset` must be greater than or equal to zero. I can't get future images of Earth for now."
        )
    ''' start to download picture '''

    print("Updating...")
    ''' get latest updating time '''
    url = 'http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json'
    latest_json = urllib2.urlopen(url)
    latest = strptime(
        loads(latest_json.read().decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")
    print("Latest version: {} GMT".format(strftime("%Y/%m/%d %H:%M:%S",
                                                   latest)))

    if auto_offset or hour_offset > 0:
        requested_time = get_time_offset(latest)
        print("Offset version: {} GMT".format(
            strftime("%Y/%m/%d %H:%M:%S", requested_time)))
    else:
        requested_time = latest

    print
    ''' use Python Imaging Library (PIL) to generate png '''
    png = Image.new('RGB', (width * level, height * level))

    counter = multiprocessing.Value("i", 0)
    p = multiprocessing.Pool(multiprocessing.cpu_count() * level)
    print("Downloading tiles: 0/%s completed" % (level * level))
    res = p.map(download_chunk,
                product(range(level), range(level), (requested_time, )))

    for (x, y, tiledata) in res:
        tile = Image.open(BytesIO(tiledata))
        png.paste(tile,
                  (width * x, height * y, width * (x + 1), height * (y + 1)))

    print("\nSaving to '%s'..." % (output_file))
    if not os.path.exists(os.path.dirname(output_file)):
        os.makedirs(os.path.dirname(output_file))
    png.save(output_file, "PNG")

    if not set_background(output_file):
        exit("Your desktop environment '{}' is not supported.".format(
            get_desktop_environment()))

    print("Done!")
Ejemplo n.º 3
0
def main():
    global counter

    print("Updating...")
    with urlopen("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json") as latest_json:
        latest = strptime(loads(latest_json.read().decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT\n".format(strftime("%Y/%m/%d %H:%M:%S", latest)))

    png = Image.new('RGB', (width*level, height*level))

    counter = Value("i", 0)
    p = Pool(cpu_count() * level)
    print("Downloading tiles: 0/{} completed".format(level*level), end="\r")
    res = p.map(download_chunk, product(range(level), range(level), (latest,)))

    for (x, y, tiledata) in res:
            tile = Image.open(BytesIO(tiledata))
            png.paste(tile, (width*x, height*y, width*(x+1), height*(y+1)))

    makedirs(split(output_file)[0], exist_ok=True)
    png.save(output_file, "PNG")

    de = get_desktop_environment()
    if de in ["gnome", "unity", "cinnamon", "pantheon", "gnome-classic"]:
        # Because of a bug and stupid design of gsettings, see http://askubuntu.com/a/418521/388226
        if de == "unity":
            call(["gsettings", "set", "org.gnome.desktop.background", "draw-background", "false"])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-uri", "file://" + output_file])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-options", "scaled"])
        call(["gsettings", "set", "org.gnome.desktop.background", "primary-color", "FFFFFF"])
    elif de == "mate":
        call(["gsettings", "set", "org.mate.background", "picture-filename", output_file])
    elif de == "xfce4":
        for display in xfce_displays:
            call(["xfconf-query", "--channel", "xfce4-desktop", "--property", display, "--set", output_file])
    elif de == "lxde":
        call(["pcmanfm", "--set-wallpaper", output_file, "--wallpaper-mode=fit",])
    elif de == "mac":
        call(["osascript", "-e", 'tell application "System Events"\nset theDesktops to a reference to every desktop\n'
              'repeat with aDesktop in theDesktops\n'
              'set the picture of aDesktop to \"' + output_file + '"\nend repeat\nend tell'])
        call(["killall", "Dock"])
    elif has_program("feh"):
        print("\nCouldn't detect your desktop environment ('{}'), but you have"
              "'feh' installed so we will use it.".format(de))
        environ['DISPLAY'] = ':0'
        call(["feh", "--bg-max", output_file])
    elif has_program("nitrogen"):
        print("\nCouldn't detect your desktop environment ('{}'), but you have "
              "'nitrogen' installed so we will use it.".format(de))
        environ["DISPLAY"] = ':0'
        call(["nitrogen", "--restore"])
    else:
        exit("Your desktop environment '{}' is not supported.".format(de))

    print("\nDone!\n")
Ejemplo n.º 4
0
def main():
    width = 550
    height = 550

    print("Updating...")
    with urlopen("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json") as latest_json:
        latest = strptime(loads(latest_json.read().decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT\n".format(strftime("%Y/%m/%d/%H:%M:%S", latest)))

    url_format = "http://himawari8.nict.go.jp/img/D531106/{}d/{}/{}_{}_{}.png"

    png = Image.new('RGB', (width*level, height*level))

    print("Downloading tiles: 0/{} completed".format(level*level), end="\r")
    for x in range(level):
        for y in range(level):
            with urlopen(url_format.format(level, width, strftime("%Y/%m/%d/%H%M%S", latest), x, y)) as tile_w:
                tiledata = tile_w.read()

            tile = Image.open(BytesIO(tiledata))
            png.paste(tile, (width*x, height*y, width*(x+1), height*(y+1)))

            print("Downloading tiles: {}/{} completed".format(x*level + y + 1, level*level), end="\r")
    print("\nDownloaded\n")

    makedirs(split(output_file)[0], exist_ok=True)
    png.save(output_file, "PNG")

    de = get_desktop_environment()
    if de in ["gnome", "unity", "cinnamon"]:
        # Because of a bug and stupid design of gsettings, see http://askubuntu.com/a/418521/388226
        if de == "unity":
            call(["gsettings", "set", "org.gnome.desktop.background", "draw-background", "false"])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-uri", "file://" + output_file])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-options", "scaled"])
    elif de == "mate":
        call(["gconftool-2", "-type", "string", "-set", "/desktop/gnome/background/picture_filename", '"{}"'.format(output_file)])
    elif de == "xfce4":
        call(["xfconf-query", "--channel", "xfce4-desktop", "--property", "/backdrop/screen0/monitor0/image-path", "--set", output_file])
    elif de == "lxde":
        call(["display", "-window", "root", output_file])
    elif de == "mac":
        call(["osascript","-e","tell application \"System Events\"\nset theDesktops to a reference to every desktop\nrepeat with aDesktop in theDesktops\nset the picture of aDesktop to \""+output_file+"\"\nend repeat\nend tell"])
    else:
        exit("Your desktop environment '{}' is not supported.".format(de))

    print("Done!\n")
Ejemplo n.º 5
0
    def run(self):
        ''' main function '''
        ''' get background picture from momentumdash.com '''

        print("Updating momentumdash image...")

        self.get_bg_picture()

        print("\nSaving to '%s'..." % (momentumdash_output_file))
        ''' set background picture as wallpaper '''
        ''' scaled, wallpaper, stretched, spanned '''
        if not set_background(momentumdash_output_file, "stretched"):
            exit("Your desktop environment '{}' is not supported.".format(
                get_desktop_environment()))

        print("Done!")
Ejemplo n.º 6
0
def main():
    global counter

    print("Updating...")
    with urlopen("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json") as latest_json:
        latest = strptime(loads(latest_json.read().decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT\n".format(strftime("%Y/%m/%d %H:%M:%S", latest)))

    url_format = "http://himawari8.nict.go.jp/img/D531106/{}d/{}/{}_{}_{}.png"

    png = Image.new('RGB', (width*level, height*level))

    counter = Value("i", 0)
    p = Pool(cpu_count() * level)
    print("Downloading tiles: 0/{} completed".format(level*level), end="\r")
    res = p.map(download_chunk, product(range(level), range(level), (latest,)))

    for (x, y, tiledata) in res:
            tile = Image.open(BytesIO(tiledata))
            png.paste(tile, (width*x, height*y, width*(x+1), height*(y+1)))

    makedirs(split(output_file)[0], exist_ok=True)
    png.save(output_file, "PNG")

    de = get_desktop_environment()
    if de in ["gnome", "unity", "cinnamon", "pantheon", "gnome-classic"]:
        # Because of a bug and stupid design of gsettings, see http://askubuntu.com/a/418521/388226
        if de == "unity":
            call(["gsettings", "set", "org.gnome.desktop.background", "draw-background", "false"])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-uri", "file://" + output_file])
        call(["gsettings", "set", "org.gnome.desktop.background", "picture-options", "scaled"])
    elif de == "mate":
        call(["gsettings", "set", "org.mate.background", "picture-filename", output_file])
    elif de == "xfce4":
        call(["xfconf-query", "--channel", "xfce4-desktop", "--property", "/backdrop/screen0/monitor0/image-path", "--set", output_file])
    elif de == "lxde":
        call(["display", "-window", "root", output_file])
    elif de == "use_feh":
        print("\nYou seem to be using linux without a DE; Attempting to set backgroud with feh\n")
        call(["feh", "--bg-max", output_file])
    else:
        exit("Your desktop environment '{}' is not supported.".format(de))

    print("\nDone!\n")
Ejemplo n.º 7
0
def thread_main(args):
    global counter
    global LATEST_JSON
    counter = mp.Value("i", 0)

    level = args.level  # since we are going to use it a lot of times

    print("Updating...")
    latest_json = download("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json")
    latest = strptime(json.loads(latest_json.decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT.".format(strftime("%Y/%m/%d %H:%M:%S", latest)))

    if latest_json == LATEST_JSON:
        print('Skip...')
        return
    LATEST_JSON = latest_json

    requested_time = calculate_time_offset(latest, args.auto_offset, args.offset)
    if args.auto_offset or args.offset != 10:
        print("Offset version: {} GMT.".format(strftime("%Y/%m/%d %H:%M:%S", requested_time)))

    png = Image.new("RGB", (WIDTH * level, HEIGHT * level))

    p = mp_dummy.Pool(level * level)
    print("Downloading tiles...")
    res = p.map(download_chunk, it.product(range(level), range(level), (requested_time,), (args.level,)))

    for (x, y, tiledata) in res:
        tile = Image.open(io.BytesIO(tiledata))
        png.paste(tile, (WIDTH * x, HEIGHT * y, WIDTH * (x + 1), HEIGHT * (y + 1)))

    for file in iglob(path.join(args.output_dir, "himawari-*.png")):
        os.remove(file)

    output_file = path.join(args.output_dir, strftime("himawari-%Y%m%dT%H%M%S.png", requested_time))
    print("Saving to '%s'..." % (output_file,))
    os.makedirs(path.dirname(output_file), exist_ok=True)
    png.save(output_file, "PNG")

    if sys.platform == 'win32':
        return
    if not set_background(output_file):
        sys.exit("Your desktop environment '{}' is not supported!\n".format(get_desktop_environment()))
Ejemplo n.º 8
0
def main():
    width = 550
    height = 550

    print("Updating...")
    with urlopen("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json") as latest_json:
        latest = strptime(loads(latest_json.read().decode("utf-8"))["date"], "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT\n".format(strftime("%Y/%m/%d/%H:%M:%S", latest)))

    url_format = "http://himawari8.nict.go.jp/img/D531106/{}d/{}/{}_{}_{}.png"

    png = Image.new('RGB', (width*level, height*level))

    print("Downloading tiles: 0/{} completed".format(level*level), end="\r")
    for x in range(level):
        for y in range(level):
            with urlopen(url_format.format(level, width, strftime("%Y/%m/%d/%H%M%S", latest), x, y)) as tile_w:
                tiledata = tile_w.read()

            tile = Image.open(BytesIO(tiledata))
            png.paste(tile, (width*x, height*y, width*(x+1), height*(y+1)))

            print("Downloading tiles: {}/{} completed".format(x*level + y + 1, level*level), end="\r")
    print("\nDownloaded\n")

    output_file = expanduser("~/.himawari-latest.png")
    png.save(output_file, "PNG")

    de = get_desktop_environment()
    if de in ["gnome", "unity", "cinnamon"]:
        # Because of a bug and stupid design of gsettings, see http://askubuntu.com/a/418521/388226
        system("gsettings set org.gnome.desktop.background draw-background false \
                && gsettings set org.gnome.desktop.background picture-uri file://" + output_file +
                " && gsettings set org.gnome.desktop.background picture-options scaled")
    elif de == "mate":
        system("gconftool-2 -type string -set /desktop/gnome/background/picture_filename \"{}\"".format(output_file))
    elif de == "xfce4":
        system("xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set " + output_file)
    else:
        exit("Your desktop environment '{}' is not supported.".format(de))

    print("Done!\n")
Ejemplo n.º 9
0
def main():
    width = 550
    height = 550

    print("Updating...")
    with urlopen(
            "http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json"
    ) as latest_json:
        latest = strptime(
            loads(latest_json.read().decode("utf-8"))["date"],
            "%Y-%m-%d %H:%M:%S")

    print("Latest version: {} GMT\n".format(
        strftime("%Y/%m/%d/%H:%M:%S", latest)))

    url_format = "http://himawari8.nict.go.jp/img/D531106/{}d/{}/{}_{}_{}.png"

    png = Image.new('RGB', (width * level, height * level))

    print("Downloading tiles: 0/{} completed".format(level * level), end="\r")
    for x in range(level):
        for y in range(level):
            with urlopen(
                    url_format.format(level, width,
                                      strftime("%Y/%m/%d/%H%M%S", latest), x,
                                      y)) as tile_w:
                tiledata = tile_w.read()

            tile = Image.open(BytesIO(tiledata))
            png.paste(tile, (width * x, height * y, width * (x + 1), height *
                             (y + 1)))

            print("Downloading tiles: {}/{} completed".format(
                x * level + y + 1, level * level),
                  end="\r")
    print("\nDownloaded\n")

    makedirs(split(output_file)[0], exist_ok=True)
    png.save(output_file, "PNG")

    de = get_desktop_environment()
    if de in ["gnome", "unity", "cinnamon"]:
        # Because of a bug and stupid design of gsettings, see http://askubuntu.com/a/418521/388226
        if de == "unity":
            call([
                "gsettings", "set", "org.gnome.desktop.background",
                "draw-background", "false"
            ])
        call([
            "gsettings", "set", "org.gnome.desktop.background", "picture-uri",
            "file://" + output_file
        ])
        call([
            "gsettings", "set", "org.gnome.desktop.background",
            "picture-options", "scaled"
        ])
    elif de == "mate":
        call([
            "gconftool-2", "-type", "string", "-set",
            "/desktop/gnome/background/picture_filename",
            '"{}"'.format(output_file)
        ])
    elif de == "xfce4":
        call([
            "xfconf-query", "--channel", "xfce4-desktop", "--property",
            "/backdrop/screen0/monitor0/image-path", "--set", output_file
        ])
    elif de == "lxde":
        call(["display", "-window", "root", output_file])
    else:
        exit("Your desktop environment '{}' is not supported.".format(de))

    print("Done!\n")
import webbrowser
from calendardialog import CalendarDialog
from calendarwindow import CalendarWindow
from addcalendarwindow import AddCalendarWindow
from eventwindow import EventWindow
from googlecalendarapi import GoogleCalendar
import comun
from configurator import Configuration
from preferences_dialog import Preferences
from utils import get_desktop_environment
from comun import _

DEFAULT_CURSOR = Gdk.Cursor(Gdk.CursorType.ARROW)
WAIT_CURSOR = Gdk.Cursor(Gdk.CursorType.WATCH)

if get_desktop_environment() == 'cinnamon':
    additional_components = ''
else:
    additional_components = '#progressbar,\n'
CSS = '''
window hdycolumn box list row combobox{
    padding-top: 10px;
    padding-bottom: 10px;
}
#sidewidget{
    padding: 10px;
}
window hdycolumn box list row{
    background-color: #ffffff;
    padding: 2px 8px;
    margin: 0;