def send2msg(yml_temp_name, args, alias): conn = amqp.Connection(host="127.0.0.1:5672", userid="guest", password="******", virtual_host="/", insist=False) chan = conn.channel() # cankao http://blog.csdn.net/linvo/article/details/5750987 #插入数据任务状态 print 0 job = Jobs() id = job.Insdate(object=alias, started=datetime.now(), finished="0", template_name=yml_temp_name, args=pickle.dumps(args), status=0) print 1 msg = (yml_temp_name, args, id) print msg msg = amqp.Message(pickle.dumps(msg)) msg.properties["delivery_mode"] = 2 chan.basic_publish(msg, exchange="sorting_room", routing_key="json") chan.close() conn.close()
def recv_callback(msg): #获取消息传来的值作为参数处理 yml_temp_name, args, id = pickle.loads(msg.body) pb = os.path.join(os.path.join('/root', yml_temp_name), 'main.yml') #拼合剧本路径 #print pb #print args status = ansible_book(pb, args, id) job = Jobs() for key, value in json.loads(status).items(): if value['unreachable'] != 0: #更新任务状态 job.Simple_update(finished=datetime.now(), status=1, id=id) elif value['failures'] != 0: job.Simple_update(finished=datetime.now(), status=2, id=id) else: job.Simple_update(finished=datetime.now(), status=3, id=id)
def post(self): user = users.get_current_user() if user: profile_key = ndb.Key('Profile',user.email()) job = Jobs(parent=profile_key) job.company = self.request.get('company') job.address = self.request.get('address') job.geopoint = get_geo(self.request.get('address')) job.description = self.request.get('description') job.position = self.request.get('position') job.link = self.request.get('link') job.put() self.redirect('/jobs/')
def post(self): s = self.request.get('s').title().strip() user = users.get_current_user() logout_url = users.create_logout_url(self.request.uri) login_url = users.create_login_url(self.request.uri) profiles = Profile.query(ndb.OR(Profile.firstname==s,Profile.lastname==s)) resumes = Resumes.query(Resumes.position==s) jobs = Jobs.query(ndb.OR(Jobs.position==s,Jobs.company==s)) self.render_multi_json(resumes=resumes,profiles=profiles,jobs=jobs)
def reset(self): NUM_MACHINES = self.config['NUM_MACHINES'] NUM_JOBS = self.config['NUM_JOBS'] self.machines = [Machine(i) for i in range(NUM_MACHINES)] self.jobs = [Jobs(i) for i in range(NUM_JOBS)] self.NOW = 0 self.jobs_processed = np.zeros( (self.config['NUM_MACHINES'], self.config['NUM_JOBS']), dtype=np.int8) return self.returnObs()
def get(self): user = users.get_current_user() logout_url = users.create_logout_url(self.request.uri) login_url = users.create_login_url(self.request.uri) if user: profile_key = ndb.Key('Profile',user.email()) jobs = Jobs.query(ancestor=profile_key) values = { 'jobs' : jobs, 'user' : user, 'logout_url' : logout_url, 'login_url' : login_url, } self.render_html('jobs.html',values) else: self.redirect(login_url)
def post(self): s = self.request.get('s') user = users.get_current_user() logout_url = users.create_logout_url(self.request.uri) login_url = users.create_login_url(self.request.uri) profiles = Profile.query(ndb.OR(Profile.firstname==s,Profile.lastname==s)) resumes = Resumes.query(Resumes.position==s) jobs = Jobs.query(ndb.OR(Jobs.position==s,Jobs.company==s)) if user: current_user = '******'+ user.nickname() user_url = logout_url title = "Click to logout from Google." values = { 'current_user' : current_user, 'user_url' : user_url, 'profiles' : profiles, 'resumes' : resumes, 'jobs' : jobs, 's' : self.request.get('s'), } self.render_html('search.html',values)
def get(self): jobs = Jobs.query().fetch() self.render_json(jobs)