Example #1
0
    def test_getStatusInJobQueue(s):

        # Test the job getStatus()
        job.add(user1, operation1, parms1, ctx1)
        r = job.getStatus(1, quePath)
        s.assertEqual(s.que.inJobQueueSt, r['status'])
        s.assertFalse('result' in r)
Example #2
0
 def test_getStatusRunning(s):
     job.add(user1, operation1, parms1, ctx1)
     s.que.setResult(1, s.que.runningSt, None, ctx1, operation1)
     r = job.getStatus(1, quePath)
     #print 'r:', r
     s.assertEqual(s.que.runningSt, r['status'])
     s.assertFalse('result' in r)
Example #3
0
    def test__getStatus(s):

        # Test the queue getStatus()
        job.add(user1, operation1, parms1, ctx1)
        r = s.que.getStatus(1)
        s.assertEqual(s.que.inJobQueueSt, r['status'])
        s.assertFalse('result' in r)
Example #4
0
 def test_getStatusSuccess(s):
     job.add(user1, operation1, parms1, ctx1)
     s.que.setResult(1, s.que.successSt, result1, ctx1, operation1)
     r = job.getStatus(1, quePath)
     #print 'r:', r
     s.assertEqual(s.que.successSt, r['status'])
     #s.assertEqual(json.dumps('result1'), r['result']);
     s.assertEqual(result1, r['result'])
def preCalc(data, ctx):

    # The entry point from the URL routing.
    # @param data: data from the HTTP post request
    # @param ctx: job context
    # @return: result of _calcComplete()

    _validateParms(data)

    # Execute the job immediately for debugging.
    #return calcMain(data, ctx)

    # Add this task to the job queue.
    return job.add(data['email'], 'createMap', data, ctx)
Example #6
0
    def test_add(s):
        r = job.add(user1, operation1, parms1, ctx1)
        task1 = job._packTask(operation1, parms1, ctx1)

        # Verify correct job ID & status was returned.
        s.assertEqual(1, r['jobId'])
        s.assertEqual(s.que.inJobQueueSt, r['status'])

        # Verify fields were initialized properly.
        out = s.que._getOne(1)
        #print 'out:', out
        s.assertEqual(s.que.inJobQueueSt, out[s.que.statusI])
        s.assertEqual(user1, out[s.que.emailI])
        s.assertEqual(today, out[s.que.lastAccessI])
        s.assertEqual(None, out[s.que.processIdI])
        s.assertEqual(task1, out[s.que.taskI])
        s.assertEqual(None, out[s.que.resultI])
    def runJob(s, data):

        # Add the job to the queue.
        r = job.add('*****@*****.**', 'placeNode', data, ctx1)
        jobId = r['jobId']
        status = r['status']

        # A new process, so we need another instance of the job runner.
        myJobProcess = JobProcess(quePath)

        # Prepare the task in the same form as it is stored in the queue.
        task = job._packTask('placeNode', data, ctx1)

        # Execute the job.
        jobProcess.main([quePath, jobId])

        # Return the result of the job.
        return s.jobQueue.getStatus(1)
Example #8
0
def preCalc(dataIn, ctx):
    '''
    The entry point from the www URL routing.
    @param dataIn: data from the HTTP post request
    @param ctx: global context
    @return: result of calcComplete()
    '''
    _validateParms(dataIn)

    if hasattr(ctx, 'overlayNodes'):

        # Execute the job immediately when using the older API.
        return calcMain(dataIn, ctx)

    # Add the job to the job queue.
    email = None
    if 'email' in dataIn:
        email = dataIn['email']

    return job.add(email, 'placeNode', dataIn, ctx)
Example #9
0
    def _cb_dr_on_recv_stream(self, stream, message):
        """
            Callback on the Dealer Router process.

            Responds as fast as possible.
        """
        log.debug("Dealer Router Message: %r" % (message), level=8)
        dealer_identity = message[0]
        notification = message[1]

        done = False
        attempts = 0
        while not done:
            attempts += 1
            try:
                _job = job.add(dealer_identity, notification)
                if not _job == None:
                    done = True
            except Exception, errmsg:
                if attempts % 10 == 0:
                    log.error("Dealer Router cannot add jobs: %r" % (errmsg))
Example #10
0
def jobs(db):
    print("Jobs")
    print()
    print("*" * 30)
    print()
    print("Current jobs are:")
    job.read(db)
    print()
    print("*" * 30)
    print("1. Add a new job.")
    print("2. Modify a job.")
    print("3. Delete a job.")
    print("4. List jobs.")
    print("5. Search jobs.")
    print("6. Go to main menu.")
    print("7. Exit.")
    print()
    job_choice = input("What would you like to do? ")
    if job_choice == "1":
        updated_on = datetime.datetime.now().isoformat()
        job_name = input("What is the job position? ")
        print("The last 5 companies entered are:")
        company.last_entries(db, 5)
        job_company_link = input("To what company would you like to link it?")
        job_requirements = input(
            "Would you like to add a requirements document?")
        if job_requirements.lower() == "y" or job_requirements.lower(
        ) == "yes":
            job_requirements = input("Type the document name and location: ")
            job_requirements_blob = database.convert_to_binary_data(
                job_requirements)
        else:
            job_requirements_blob = ""
        job.add(db, updated_on, job_company_link, job_name,
                job_requirements_blob)
        companies(db)
    elif job_choice == "2":
        updated_on = datetime.datetime.now().isoformat()
        modify_job = input("What job position would you like to change? ")
        old_job = job.get_one(db, modify_job)
        print("What is the new job name (", old_job[4], ")? \
        (ENTER to leave unchanged)")
        new_job_name = input("> ")
        if new_job_name == "":
            new_job_name = old_job[4]
        print("The last 5 companies entered are:")
        company.last_entries(db, 5)
        input()

        job.modify(db, modify_job, new_job_name)
        jobs(db)
    elif job_choice == "3":
        delete_job = input("Company to delete? ")
        job.delete(db, delete_job)
        jobs(db)
    elif job_choice == "4":
        how_many = input("Last how many entries? ")
        job.last_entries(db, how_many)
        jobs(db)
    elif job_choice == "5":
        search_job = input("Company to search for? ")
        job.search(db, search_job)
        jobs(db)
    elif job_choice == "6":
        main(db)
    elif job_choice == "7":
        goodbye(db)
    else:
        invalid_input()
        jobs(db)
Example #11
0
def preCalc(parms, ctx):
    userEmail = parms['email']
    return job.add(userEmail, "statsLayout", parms, ctx)
Example #12
0
 def test_getStatusErrorWithTrace(s):
     job.add(user1, operation1, parms1, ctx1)
     s.que.setResult(1, s.que.errorSt, errorMsg1trace, ctx1, operation1)
     r = job.getStatus(1, quePath)
     s.assertEqual(s.que.errorSt, r['status'])
     s.assertEqual(errorMsg1trace, r['result'])
Example #13
0
 def test_getOne(s):
     job.add(user1, operation1, parms1, ctx1)
     aJob = s.que._getOne(1)
     s.assertEqual(1, aJob[s.que.idI])
Example #14
0
def preCalc(parms, ctx):
    userEmail = parms['email']
    return job.add(userEmail, "reflect", parms, ctx)