示例#1
0
 def test_make_dir(self):
     testdir = os.path.join(os.path.expanduser("~"), '.test')
     make_dir(testdir)
     self.assertTrue(os.path.exists(testdir))
     if sys.platform.startswith('linux'):
         self.assertEqual(oct(os.stat(testdir).st_mode)[-3:], '777')
     shutil.rmtree(testdir)
示例#2
0
文件: utils.py 项目: ananyo2012/UIP
def flush_wallpapers(folder):
    """Delete all downloaded wallpapers."""
    print("Deleting all downloaded wallpapers...")
    try:
        shutil.rmtree(folder)
        make_dir(folder)
    except FileNotFoundError:
        pass
示例#3
0
 def test_flush_wallpapers(self):
     testdir = os.path.join(os.path.expanduser("~"), '.WAKEUPDOLORES')
     setupUtils.make_dir(testdir)
     test_dir_to_delete = os.path.join(testdir, 'tobedeleted')
     setupUtils.make_dir(test_dir_to_delete)
     utils.flush_wallpapers(testdir)
     self.assertEqual(os.listdir(testdir), [])
     shutil.rmtree(testdir)
示例#4
0
文件: UIP.py 项目: DarkSouL11/UIP
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()
示例#5
0
            packages.extend([os.path.join(path, dir) for dir in dirs])
    return packages


def get_requirements(filename):
    """Method to get the requirements of the specified file."""
    file = open(filename, 'r').readlines()
    out = []
    for a in file:
        out.append(a.strip())
    return out


# Make Home Directory
if not os.path.exists(HOME_DIR):
    make_dir(HOME_DIR)

if not os.path.exists(DEFAULT_PICS_FOLDER):
    make_dir(DEFAULT_PICS_FOLDER)

if not os.path.exists(DEFAULT_FAVOURITE_PICS_FOLDER):
    make_dir(DEFAULT_FAVOURITE_PICS_FOLDER)

if not os.path.isfile(settings_file_path):
    file_data = DEFAULT_SETTINGS

    with open(settings_file_path, "w") as settings_file:
        settings_file.write(json.dumps(file_data, indent=4, sort_keys=True))

requirements = get_requirements('requirements.txt')
示例#6
0
        if '__init__.py' in files:
            packages.extend([os.path.join(path, dir) for dir in dirs])
    return packages


def get_requirements(filename):
    """Method to get the requirements of the specified file."""
    file = open(filename, 'r').readlines()
    out = []
    for a in file:
        out.append(a.strip())
    return out

# Make Home Directory
if not os.path.exists(HOME_DIR):
    make_dir(HOME_DIR)

if not os.path.exists(DEFAULT_PICS_FOLDER):
    make_dir(DEFAULT_PICS_FOLDER)

if not os.path.isfile(settings_file_path):
    file_data = {'timeout': 30*60,
                 'no-of-images': NUMBER_OF_IMAGES_TO_PARSE,
                 'pics-folder': DEFAULT_PICS_FOLDER,
                 'website': ['https://unsplash.com/new',
                             'https://www.reddit.com/r/wallpapers/',
                             'https://www.reddit.com/r/wallpaper/',
                             'https://www.reddit.com/r/EarthPorn/',
                             'https://www.reddit.com/r/VillagePorn/',
                             'https://www.reddit.com/r/pics/',
                             'https://api.desktoppr.co/1/wallpapers', ]}