Esempio n. 1
0
File: UIP.py Progetto: hassi2016/UIP
def main():
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper."
          " \n Press ctrl-c to exit")
    parser = argparse.ArgumentParser()
    parser.add_argument("--offline",
                        action="store_true",
                        help="Runs UIP in offline mode.")
    parser.add_argument("--flush",
                        action="store_true",
                        help="Delete all downloaded wallpapers"
                        " and downloads new ones. "
                        "When combined with --offline,"
                        " deletes the wallpapers and exits.")
    args = parser.parse_args()
    try:
        if args.offline:
            print("You have choosen to run UIP in offline mode.")
        if args.flush:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(os.path.join(CURR_DIR, PICS_FOLDER))
                os.mkdir(os.path.join(CURR_DIR, PICS_FOLDER))
            except FileNotFoundError:
                pass
        if not args.offline:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(args.offline)
    except KeyboardInterrupt:
        print("Exiting UIP hope you had a nice time :)")
        sys.exit(0)
Esempio n. 2
0
def main():
    """Main method of the UIP."""
    settingsParser = ParseSettings()
    settings = settingsParser.settings
    pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid')
    if settings['error']:
        print("\nWRONG USAGE OF FLAGS, see --help")
        settingsParser.show_help()
        exit_UIP()
    if settings['service']:
        if 'start' == str(settings['service']):
            with Daemonizer() as (is_setup, daemonizer):
                if is_setup:
                    print("UIP will now run as a serice.")
                try:
                    is_parent = daemonizer(pid_file)
                except SystemExit:
                    print("UIP service already, running "
                          "Close previous app by running UIP --service stop")
                    sys.exit(0)

        elif 'stop' == str(settings['service']):
            exit_UIP()
        else:
            print('Wrong option for service flag see --help')

    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper."
          " \nPress ctrl-c to exit")
    try:
        if settings['offline']:
            print("You have choosen to run UIP in offline mode.")
        if settings['flush']:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(settings['pics-folder'])
                make_dir(settings['pics-folder'])
            except FileNotFoundError:
                pass
        if not settings['offline']:
            print("UIP will now connect to internet and download images"
                  " from reddit and unsplash.")
        if settings['ui']:
            from uiplib.gui.mainGui import MainWindow
            app = MainWindow(settings)
            app.run()
            exit_UIP()
        scheduler(settings['offline'], settings['pics-folder'],
                  settings['timeout'], settings['website'],
                  settings['no-of-images'], settings['service'])
    except KeyboardInterrupt:
        exit_UIP()
Esempio n. 3
0
def main():
    settingsParser = ParseSettings()
    settings = settingsParser.settings
    pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid')
    if settings['service']:
        if 'start' == str(settings['service']):
            with Daemonizer() as (is_setup, daemonizer):
                if is_setup:
                    print("UIP will now run as a serice.")
                try:
                    is_parent = daemonizer(pid_file)
                except SystemExit:
                    print("UIP service already, running "
                          "Close previous app by running UIP --service stop")

        elif 'stop' == str(settings['service']):
            try:
                send(pid_file, SIGTERM)
                os.remove(pid_file)
                sys.exit(0)
            except Exception as e:
                print("you need to start a service first", str(e))
                sys.exit(0)
        else:
            print('Wrong option for service flag see --help')

    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper."
          " \nPress ctrl-c to exit")
    try:
        if settings['error']:
            print("\nWRONG USAGE OF FLAGS --no-of-images AND --offline")
            settingsParser.show_help()
            sys.exit(0)
        if settings['offline']:
            print("You have choosen to run UIP in offline mode.")
        if settings['flush']:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(settings['pics-folder'])
                os.mkdir(settings['pics-folder'])
            except FileNotFoundError:
                pass
        if not settings['offline']:
            print("UIP will now connect to internet and download images"
                  " from reddit and unsplash.")
        scheduler(settings['offline'], settings['pics-folder'],
                  settings['timeout'], settings['website'],
                  settings['no-of-images'])
    except KeyboardInterrupt:
        print("Exiting UIP hope you had a nice time :)")
        sys.exit(0)
Esempio n. 4
0
 def play(self):
     """Start scheduling wallpapers."""
     if not self.scheduler_object:
         self.scheduler_object = scheduler(self.settings['offline'],
                                           self.settings['pics-folder'],
                                           self.settings['timeout'],
                                           self.settings['website'],
                                           self.settings['no-of-images'],
                                           not (self.settings['service'] or
                                                self.settings['ui']),
                                           self.wallpaper,
                                           appObj=self)
Esempio n. 5
0
import sys
from uiplib.scheduler import scheduler

if __name__ == "__main__":
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    try:
        offline = False
        if len(sys.argv) > 1 and str(sys.argv[1]) == '--offline':
            print("You have choosen to run UIP in offline mode.")
            offline = True
        else:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(offline)
    except KeyboardInterrupt:
        sys.exit(0)
Esempio n. 6
0
File: UIP.py Progetto: trump16/UIP
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    parser = argparse.ArgumentParser()
    parser.add_argument("--offline",
                        action="store_true",
                        help="Runs UIP in offline mode.")
    parser.add_argument("--flush",
                        action="store_true",
                        help="Delete all downloaded wallpapers"
                        " and downloads new ones. "
                        "When combined with --offline,"
                        " deletes the wallpapers and exits.")
    args = parser.parse_args()
    try:
        if args.offline:
            print("You have choosen to run UIP in offline mode.")
        if args.flush:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(os.path.join(CURR_DIR, PICS_FOLDER))
                os.mkdir(os.path.join(CURR_DIR, PICS_FOLDER))
            except FileNotFoundError:
                pass
        if not args.offline:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(args.offline)
    except KeyboardInterrupt:
        sys.exit(0)