def force_job(command, name='', frequency='YEARLY', stop=False, **kwargs):
 jobs = Job.objects.filter(command=command)
 if (jobs.count() > 0):
  job = jobs[0]
 else:
  job = Job(command=command)
 job.frequency = frequency
 job.name = (job.name or name or command)
 job.save()
 if stop:
  job.is_running = False
 else:
  job.next_run = datetime.now()
  job.args = ' '.join([('%s=%s' % (k, v)) for (k, v) in kwargs.iteritems()])
 job.save()
 launch_job = ((not stop) and (not job.is_running))
 if launch_job:
  if (Job.objects.filter(disabled=False, is_running=False, next_run__lte=datetime.now()).count() > 0):
   call_command_async('cron')

def force_job ( command , name = '' , frequency = 'YEARLY' , stop = False , ** kwargs ) : jobs = Job . objects . filter ( command = command ) if ( jobs . count ( ) > 0 ) : job = jobs [ 0 ] else : job = Job ( command = command ) job . frequency = frequency job . name = ( job . name or name or command ) job . save ( ) if stop : job . is_running = False else : job . next_run = datetime . now ( ) job . args = ' ' . join ( [ ( '%s=%s' % ( k , v ) ) for ( k , v ) in kwargs . iteritems ( ) ] ) job . save ( ) launch_job = ( ( not stop ) and ( not job . is_running ) ) if launch_job : if ( Job . objects . filter ( disabled = False , is_running = False , next_run__lte = datetime . now ( ) ) . count ( ) > 0 ) : call_command_async ( 'cron' )
mark a job as to run immediately .