Exemplo n.º 1
0
class HaveDate(Boobmsg):
    APPNAME = 'havedate'
    VERSION = '0.e'
    COPYRIGHT = 'Copyright(C) 2010-2012 Romain Bignon'
    DESCRIPTION = 'Console application allowing to interact with various dating websites ' \
                  'and to optimize seduction algorithmically.'
    STORAGE_FILENAME = 'dating.storage'
    STORAGE = {'optims': {}}
    CAPS = ICapDating
    EXTRA_FORMATTERS = copy(Boobmsg.EXTRA_FORMATTERS)
    EXTRA_FORMATTERS['events'] = EventListFormatter
    COMMANDS_FORMATTERS = copy(Boobmsg.COMMANDS_FORMATTERS)
    COMMANDS_FORMATTERS['optim'] = 'table'
    COMMANDS_FORMATTERS['events'] = 'events'

    def load_default_backends(self):
        self.load_backends(ICapDating,
                           storage=self.create_storage(self.STORAGE_FILENAME))

    def main(self, argv):
        self.load_config()

        try:
            self.do('init_optimizations').wait()
        except CallErrors, e:
            self.bcall_errors_handler(e)

        optimizations = self.storage.get('optims')
        for optim, backends in optimizations.iteritems():
            self.optims('start', backends, optim, store=False)

        return ReplApplication.main(self, argv)
Exemplo n.º 2
0
 def bcall_error_handler(self, backend, error, backtrace):
     if isinstance(error, SensorNotFound):
         msg = unicode(
             error) or 'Sensor not found (hint: try details command)'
         print('Error(%s): %s' % (backend.name, msg), file=self.stderr)
     else:
         return ReplApplication.bcall_error_handler(self, backend, error,
                                                    backtrace)
Exemplo n.º 3
0
 def parse_id(self, id):
     if self.interactive:
         try:
             account = self.accounts[int(id) - 1]
         except (IndexError,ValueError):
             pass
         else:
             return account.id, account.backend
     return ReplApplication.parse_id(self, id)
Exemplo n.º 4
0
 def parse_id(self, id):
     if self.interactive:
         try:
             torrent = self.torrents[int(id) - 1]
         except (IndexError,ValueError):
             pass
         else:
             id = '%s@%s' % (torrent.id, torrent.backend)
     return ReplApplication.parse_id(self, id)
Exemplo n.º 5
0
    def main(self, argv):
        self.load_config()

        try:
            self.do('init_optimizations').wait()
        except CallErrors as e:
            self.bcall_errors_handler(e)

        optimizations = self.storage.get('optims')
        for optim, backends in optimizations.iteritems():
            self.optims('start', backends, optim, store=False)

        return ReplApplication.main(self, argv)
Exemplo n.º 6
0
    def main(self, argv):
        if len(argv) < 2:
            print >>self.stderr, 'Please give the name of the boobathon'
            return 1

        self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
        if self.event.description is None:
            if not self.ask("This event doesn't seem to exist. Do you want to create it?", default=True):
                return 1
            self.edit_event()
            self.save_event('Event created')

        return ReplApplication.main(self, [argv[0]])
Exemplo n.º 7
0
    def main(self, argv):
        if len(argv) < 2:
            print('Please give the name of the boobathon', file=self.stderr)
            return 1

        self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
        if self.event.description is None:
            if not self.ask("This event doesn't seem to exist. Do you want to create it?", default=True):
                return 1
            self.edit_event()
            self.save_event('Event created')

        return ReplApplication.main(self, [argv[0]])
Exemplo n.º 8
0
    def main(self, argv):
        self.load_config()

        try:
            self.do('init_optimizations').wait()
        except CallErrors as e:
            self.bcall_errors_handler(e)

        optimizations = self.storage.get('optims')
        for optim, backends in optimizations.iteritems():
            self.optims('start', backends, optim, store=False)

        return ReplApplication.main(self, argv)
Exemplo n.º 9
0
    def main(self, argv):
        self.load_config()
        try:
            self.config.set('interval', int(self.config.get('interval')))
            if self.config.get('interval') < 1:
                raise ValueError()
        except ValueError:
            print >> sys.stderr, 'Configuration error: interval must be an integer >0.'
            return 1

        try:
            self.config.set('html', int(self.config.get('html')))
            if self.config.get('html') not in (0, 1):
                raise ValueError()
        except ValueError:
            print >> sys.stderr, 'Configuration error: html must be 0 or 1.'
            return 2

        return ReplApplication.main(self, argv)
Exemplo n.º 10
0
    def main(self, argv):
        self.load_config()
        try:
            self.config.set('interval', int(self.config.get('interval')))
            if self.config.get('interval') < 1:
                raise ValueError()
        except ValueError:
            print('Configuration error: interval must be an integer >0.', file=self.stderr)
            return 1

        try:
            self.config.set('html', int(self.config.get('html')))
            if self.config.get('html') not in (0, 1):
                raise ValueError()
        except ValueError:
            print('Configuration error: html must be 0 or 1.', file=self.stderr)
            return 2

        return ReplApplication.main(self, argv)
Exemplo n.º 11
0
 def bcall_error_handler(self, backend, error, backtrace):
     if isinstance(error, TransferStep):
         params = {}
         for field in error.fields:
             v = self.ask(field)
             if v:
                 params[field.id] = v
         #backend.config['accept_transfer'].set(v)
         params['backends'] = backend
         self.start_format()
         for transfer in self.do('transfer', error.transfer, **params):
             self.format(transfer)
     elif isinstance(error, AddRecipientStep):
         params = {}
         params['backends'] = backend
         for field in error.fields:
             v = self.ask(field)
             if v:
                 params[field.id] = v
         next(iter(self.do('add_recipient', error.recipient, **params)))
     else:
         return ReplApplication.bcall_error_handler(self, backend, error,
                                                    backtrace)
Exemplo n.º 12
0
 def __init__(self, *args, **kwargs):
     ReplApplication.__init__(self, *args, **kwargs)
Exemplo n.º 13
0
 def __init__(self, *args, **kwargs):
     ReplApplication.__init__(self, *args, **kwargs)
     self.player = MediaPlayer(self.logger)
Exemplo n.º 14
0
 def __init__(self, *args, **kwargs):
     ReplApplication.__init__(self, *args, **kwargs)
     self.player = MediaPlayer(self.logger)
Exemplo n.º 15
0
 def __init__(self, *args, **kwargs):
     ReplApplication.__init__(self, *args, **kwargs)
Exemplo n.º 16
0
 def bcall_error_handler(self, backend, error, backtrace):
     if isinstance(error, SensorNotFound):
         msg = unicode(error) or 'Sensor not found (hint: try details command)'
         print('Error(%s): %s' % (backend.name, msg), file=self.stderr)
     else:
         return ReplApplication.bcall_error_handler(self, backend, error, backtrace)
Exemplo n.º 17
0
 def main(self, argv):
     self.load_config(klass=YamlConfig)
     return ReplApplication.main(self, argv)
Exemplo n.º 18
0
 def main(self, argv):
     self.load_config()
     return ReplApplication.main(self, argv)
Exemplo n.º 19
0
 def main(self, argv):
     self.load_config()
     return ReplApplication.main(self, argv)
Exemplo n.º 20
0
 def main(self, argv):
     self.load_config(klass=YamlConfig)
     return ReplApplication.main(self, argv)