def runjob(self, app_name, job_name, options):
     if options.get('verbose', False):
         print "Executing job: %s (app: %s)" % (job_name, app_name)
     try:
         job = get_job(app_name, job_name)
     except KeyError, e:
         if app_name:
             print "Error: Job %s for applabel %s not found" % (app_name, job_name)
         else:
             print "Error: Job %s not found" % job_name
         print "Use -l option to view all the available jobs"
         return
示例#2
0
 def runjob(self, app_name, job_name, options):
     verbosity = int(options.get('verbosity', 1))
     if verbosity>1:
         print "Executing job: %s (app: %s)" % (job_name, app_name)
     try:
         job = get_job(app_name, job_name)
     except KeyError, e:
         if app_name:
             print "Error: Job %s for applabel %s not found" % (app_name, job_name)
         else:
             print "Error: Job %s not found" % job_name
         print "Use -l option to view all the available jobs"
         return
示例#3
0
    def test_leave_messages(self):
        hear_url = reverse('chat.hear')

        # make two appearances
        self.client.login(username='******', password='******')
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)

        self.client.login(username='******', password='******')
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)

        self.assertEqual(Appearance.objects.count(), 2)
        # pretend that superjoe's appearance was settings.CHAT_TIMEOUT + 1
        # seconds ago
        appear = Appearance.objects.filter(person=self.superjoe)[0]
        new_ts = datetime.now() - timedelta(seconds=(settings.CHAT_TIMEOUT +
                                                     1))
        appear.timestamp = new_ts
        appear._save()  # bypass the auto timestamp update
        appear = Appearance.objects.filter(person=self.superjoe)[0]
        self.assertEqual(appear.timestamp, new_ts)

        # run the job
        job = get_job('chat', 'leave')
        job().execute()

        # there should be a part message in the chat room
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEqual(data['user']['permission_read'], True)
        self.assertEqual(data['user']['permission_write'], True)
        # 3 messages: join, join, leave
        self.assertEqual(len(data['messages']), 3)
        # have to sort locally
        data['messages'].sort(lambda x, y: cmp(x['id'], y['id']))
        self.assertEqual(data['messages'][2]['type'], ChatMessage.LEAVE)
        self.assertEqual(data['messages'][2]['author']['username'], 'superjoe')

        # now there should be 1 appearance
        self.assertEqual(Appearance.objects.count(), 1)
示例#4
0
    def test_leave_messages(self):
        hear_url = reverse('chat.hear')

        # make two appearances
        self.client.login(username='******', password='******')
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)

        self.client.login(username='******', password='******')
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)

        self.assertEqual(Appearance.objects.count(), 2)
        # pretend that superjoe's appearance was settings.CHAT_TIMEOUT + 1
        # seconds ago
        appear = Appearance.objects.filter(person=self.superjoe)[0]
        new_ts = datetime.now() - timedelta(seconds=(settings.CHAT_TIMEOUT+1))
        appear.timestamp = new_ts
        appear._save() # bypass the auto timestamp update
        appear = Appearance.objects.filter(person=self.superjoe)[0]
        self.assertEqual(appear.timestamp, new_ts)

        # run the job
        job = get_job('chat', 'leave')
        job().execute()

        # there should be a part message in the chat room
        response = self.client.get(hear_url, {
            'last_message': 'null',
            'room': self.open_room.id,
        })
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEqual(data['user']['permission_read'], True)
        self.assertEqual(data['user']['permission_write'], True)
        # 3 messages: join, join, leave
        self.assertEqual(len(data['messages']), 3)
        # have to sort locally
        data['messages'].sort(lambda x, y: cmp(x['id'], y['id']))
        self.assertEqual(data['messages'][2]['type'], ChatMessage.LEAVE)
        self.assertEqual(data['messages'][2]['author']['username'], 'superjoe')


        # now there should be 1 appearance
        self.assertEqual(Appearance.objects.count(), 1)
示例#5
0
 def runjob(self, app_name, job_name, options):
     verbosity = options["verbosity"]
     if verbosity > 1:
         logger.info("Executing job: %s (app: %s)", job_name, app_name)
     try:
         job = get_job(app_name, job_name)
     except KeyError:
         if app_name:
             logger.error("Error: Job %s for applabel %s not found", job_name, app_name)
         else:
             logger.error("Error: Job %s not found", job_name)
         logger.info("Use -l option to view all the available jobs")
         return
     try:
         job().execute()
     except Exception:
         logger.exception("ERROR OCCURED IN JOB: %s (APP: %s)", job_name, app_name)
示例#6
0
 def runjob(
     self,
     app_name,
     job_name,
     options,
     ):
     verbosity = int(options.get('verbosity', 1))
     if verbosity > 1:
         print 'Executing job: %s (app: %s)' % (job_name, app_name)
     try:
         job = get_job(app_name, job_name)
     except KeyError, e:
         if app_name:
             print 'Error: Job %s for applabel %s not found' \
                 % (app_name, job_name)
         else:
             print 'Error: Job %s not found' % job_name
         print 'Use -l option to view all the available jobs'
         return
示例#7
0
文件: runjob.py 项目: 18600597055/hue
 def runjob(self, app_name, job_name, options):
     verbosity = int(options.get('verbosity', 1))
     if verbosity > 1:
         print("Executing job: %s (app: %s)" % (job_name, app_name))
     try:
         job = get_job(app_name, job_name)
     except KeyError:
         if app_name:
             print("Error: Job %s for applabel %s not found" % (job_name, app_name))
         else:
             print("Error: Job %s not found" % job_name)
         print("Use -l option to view all the available jobs")
         return
     try:
         job().execute()
     except Exception:
         import traceback
         print("ERROR OCCURED IN JOB: %s (APP: %s)" % (job_name, app_name))
         print("START TRACEBACK:")
         traceback.print_exc()
         print("END TRACEBACK\n")
示例#8
0
 def runjob(self, app_name, job_name, options):
     verbosity = int(options.get('verbosity', 1))
     if verbosity > 1:
         print("Executing job: %s (app: %s)" % (job_name, app_name))
     try:
         job = get_job(app_name, job_name)
     except KeyError:
         if app_name:
             print("Error: Job %s for applabel %s not found" % (job_name, app_name))
         else:
             print("Error: Job %s not found" % job_name)
         print("Use -l option to view all the available jobs")
         return
     try:
         job().execute()
     except Exception:
         import traceback
         print("ERROR OCCURED IN JOB: %s (APP: %s)" % (job_name, app_name))
         print("START TRACEBACK:")
         traceback.print_exc()
         print("END TRACEBACK\n")