예제 #1
0
파일: style.py 프로젝트: tarunkota/wallp
	def exc_desktop_call(self, meth, *args, **kwargs):
		if self._desktop is None:
			self._desktop = get_desktop()

		try:
			m = getattr(self._desktop.__class__, meth, None)
			if m is None:
				print('method %s not found in class %s'%(meth, self._desktop.__class__.__name__))
				raise CommandError()

			return m(self._desktop, *args, **kwargs)
		except (WPStyleError, DesktopError) as e:
			print(e)
			raise CommandError()
예제 #2
0
 def exc_call(self, method):
     try:
         score = method()
         print('image score: %d' % score)
     except DBImageError as e:
         print(str(e))
         raise CommandError()
예제 #3
0
 def config_call(self, func, *args):
     try:
         r = func(*args)
         return r
     except (ConfigError, ValueError) as e:
         print(str(e))
         raise CommandError()
예제 #4
0
파일: info.py 프로젝트: tarunkota/wallp
 def get_wallpaper_image(self):
     try:
         db_images = DBImages()
         image = db_images.get_current_wallpaper_image()
     except DBImageError as e:
         print(e)
         raise CommandError()
     return image
예제 #5
0
파일: keep.py 프로젝트: tarunkota/wallp
    def keep(self, period):
        '''Keep the wallpaper unchanged for a certain period of time.
		period: time period'''

        try:
            exp_period = self.keep_wallpaper(period)
            print('wallpaper will stick for next %s' % exp_period)
        except KeepError as e:
            print(str(e))
            raise CommandError()
예제 #6
0
파일: schedule.py 프로젝트: tarunkota/wallp
	def add(self, frequency):
		'''Add schedule.
		frequency: time frequency for changing wallpaper'''

		scheduler = Scheduler()
		try:
			scheduler.set_frequency(frequency)
		except SchedulerError as e:
			print(str(e))
			raise CommandError()
예제 #7
0
 def player_list_error_wrapped(self, method, *args, **kwargs):
     try:
         return method(*args, **kwargs)
     except PlayerListError as e:
         print(e)
         raise CommandError()
     except AttributeError as e:
         # In case a command is sent to class Player and VLC is not running, the following error occurs:
         # <<'NoneType' object has no attribute 'xyz'.>>
         # This error is explicitly catched here to avoid crashing of the complete program.
         print("VLC player is not running.")
         return -1
예제 #8
0
    def validate_input(self, regex, input, err_msg):
        #import pdb; pdb.set_trace()
        match = re.compile(regex).match(input)

        if match is None:
            print(err_msg)
            raise CommandError()

        return match

        #later
        #@common
        #def instance(self, id=1, all):
        '''Common arguments for subcommands dealing with multiple instances.
예제 #9
0
파일: favorite.py 프로젝트: tarunkota/wallp
	def favorite(self, unfavorite=False):
		'''Favorite current wallpaper image.
		unfavorite: remove current wallpaper image from favorites'''

		db_images = Images()
		try:
			if not unfavorite:
				db_images.favorite_wallpaper()
				print('favorited')
			else:
				db_images.unfavorite_wallpaper()
				print('removed from favorites')
		except DBImageError as e:
			print(str(e))
			raise CommandError()
예제 #10
0
파일: base.py 프로젝트: tarunkota/wallp
    def change_wallpaper(self, params):
        exc = None

        for _ in range(0, self._repeat_count):
            try:
                wallpaper = Wallpaper(params=params)
                wallpaper.change()
            except WallpaperError as e:
                printer.printf('error', str(e))
                exc = CommandError()

            sleep(self._repeat_delay)

        if exc is not None:
            raise exc
예제 #11
0
파일: getset.py 프로젝트: tarunkota/wallp
    def dump(self):
        'Print all the configuration settings.'

        settings = self.exc_call(self._config.get_all)
        for name, value in settings:
            printer.printf(name, str(value))

        printer.printf('', '')

        try:
            sources = Sources()
            source_states = sources.get_all()
        except DBSourceError as e:
            print(e)
            raise CommandError()

        for name, enabled in source_states:
            printer.printf(name, 'enabled' if enabled else 'disabled')
예제 #12
0
 def exc_call(self, method, *args):
     try:
         method(*args)
     except DBSourceError as e:
         print(e)
         raise CommandError()
예제 #13
0
파일: getset.py 프로젝트: tarunkota/wallp
 def exc_call(self, method, *args, **kwargs):
     try:
         return method(*args, **kwargs)
     except ConfigError as e:
         print(e)
         raise CommandError()
예제 #14
0
 def player_list_error_wrapped(self, method, *args, **kwargs):
     try:
         return method(*args, **kwargs)
     except PlayerListError as e:
         print(e)
         raise CommandError()