Пример #1
0
                     mtime=_mtime)
    else:
        # check the nextdtime(m[9]) meeting ondate?over?futrue?
        #if m[9].day <= starton.day and sta == meeting.STA_FINISH:
        #	_counting += 1
        node = mnode(_mid,
                     _name,
                     mroom=_mroom,
                     rpmode=_rpmode,
                     rparg=_rparg,
                     counting=_counting,
                     ondate=_ondate,
                     ontime=_ontime,
                     mtime=_mtime,
                     p_start=_p_start,
                     p_end=_p_end)
        if node.nextdtime > _ndtime:
            print(node.nextdtime, 'over', _ndtime)
            node.force_update()
    Mqueue.auto_node(_objid, node)
#print(Mqueue.ins_queues)

try:
    from main_0 import app
except Exception as e:
    print('error: ', e)
    signal_shutdown(None, None)

if __name__ == '__main__':
    signal.signal(signal.SIGINT, signal_shutdown)
    app.run(host='0.0.0.0', port=7890)
Пример #2
0
 def newmeeting_safe2(self, params, autonode=True, getndtime=False):
     # return mid(success) or False(if conflict), if getndtime: extdata
     roomid = int(params['mroom'])
     mname = params.get('name')
     _rpmode = int(params['rpmode'])
     _ondate = params.get('ondate')
     _ontime = params['ontime']
     _mtime = int(params['mtime'])
     # with roomid, precheck
     # precheck room
     _node = None
     if roomid > 0:
         if _rpmode == mnode.RMODE_ONCE:
             if RMS.conflict_dtime(roomid, _ondate, _ontime, mtime=_mtime):
                 loger.error("create meeting but conflic")
                 self.emsg = "会议室冲突"
                 return False
         else:
             _rparg = [int(_) for _ in params['rparg'].split(',')]
             _p_start = params['p_start']
             _p_end = params['p_end']
             _node = mnode(0,
                           mname,
                           mroom=roomid,
                           rpmode=_rpmode,
                           rparg=_rparg,
                           ontime=_ontime,
                           mtime=_mtime,
                           p_start=_p_start,
                           p_end=_p_end)
             _meeting_schedule = _node.calendar(get_mode=2)
             print(_meeting_schedule)
             if RMS.conflict_schedule(roomid,
                                      _meeting_schedule,
                                      _ontime,
                                      period_from=_p_start,
                                      period_end=_p_end,
                                      mtime=_mtime):
                 loger.error("create meeting but conflic")
                 self.emsg = "会议室冲突"
                 return False
     # if no room or no conflict....
     if _rpmode == mnode.RMODE_ONCE and not self._test_ctime(
             _ondate, _ontime):
         loger.error("not allow time")
         self.emsg = "非许可时间"
         return False
     try:
         if _rpmode == mnode.RMODE_ONCE:
             _node = mnode(0,
                           mname,
                           mroom=roomid,
                           rpmode=_rpmode,
                           ondate=_ondate,
                           ontime=_ontime,
                           mtime=_mtime)
         else:
             _rparg = [int(_) for _ in params['rparg'].split(',')]
             _p_start = params['p_start']
             _p_end = params['p_end']
             # counting=0
             # if no roomid, _node not create above
             _node = _node or mnode(0,
                                    mname,
                                    mroom=roomid,
                                    rpmode=_rpmode,
                                    rparg=_rparg,
                                    ontime=_ontime,
                                    mtime=_mtime,
                                    p_start=_p_start,
                                    p_end=_p_end)
             # for first create new, nextdtime aouto make by node, put with params
             params['nextdtime'] = _node.nextdtime
     except ValueError:
         loger.error("create node wrong with params: [%s]" % params)
         return False
     mid = MEETING.new(self.objid, params)
     if mid > 0:
         _node.mid = mid
         Mqueue.auto_node(self.objid, _node)
         if getndtime:
             self.extdata = _node.nextdtime
         # create schedule if roomid
         if roomid:
             if _rpmode == mnode.RMODE_ONCE:
                 dbresult = RMS.one_meeting(roomid,
                                            mid,
                                            _ondate,
                                            _ontime,
                                            meetingtime=_mtime)
             else:
                 dbresult = RMS.repeatedly_meeting(roomid,
                                                   mid,
                                                   _meeting_schedule,
                                                   _ontime,
                                                   meetingtime=_mtime)
             loger.info(dbresult)
         return mid
     return False
Пример #3
0
 def newmeeting_safe(self, params, autonode=True, getndtime=False):
     # return int: -n | 0 | n;
     # ==> v2: return int,nextdtime
     # 0: cannot create node or insert to db
     # -n: conflict with meeting mid = n
     # n: success create meeting with mid = n
     roomid = int(params['mroom'])
     mname = params.get('name')
     _rpmode = int(params['rpmode'])
     _ondate = params.get('ondate')
     _ontime = params['ontime']
     _mtime = int(params['mtime'])
     # with roomid, precheck
     # precheck room
     if roomid > 0:
         if _rpmode == mnode.RMODE_ONCE:
             x_mid = Mqueue.get_queue(self.objid).filter_room_conflict_once(
                 roomid, _ondate, _ontime, _mtime)
         else:
             _rparg = [int(_) for _ in params['rparg'].split(',')]
             _p_start = params['p_start']
             _p_end = params['p_end']
             x_mid = Mqueue.get_queue(self.objid).filter_room_conflict(
                 _rpmode, _rparg, roomid, _ontime, _mtime, _p_start, _p_end)
         if x_mid > 0:
             loger.error("create meeting but conflic with meeting[%d]" %
                         x_mid)
             return -x_mid
     # if no room or no conflict....
     if not (_rpmode == mnode.RMODE_ONCE
             and self._test_ctime(_ondate, _ontime)):
         loger.error("not allow time")
         self.emsg = "非许可时间"
         return 0
     try:
         if _rpmode == mnode.RMODE_ONCE:
             _node = mnode(0,
                           mname,
                           mroom=roomid,
                           rpmode=_rpmode,
                           ondate=_ondate,
                           ontime=_ontime,
                           mtime=_mtime)
         else:
             _rparg = [int(_) for _ in params['rparg'].split(',')]
             _p_start = params['p_start']
             _p_end = params['p_end']
             # counting=0
             _node = mnode(0,
                           mname,
                           mroom=roomid,
                           rpmode=_rpmode,
                           rparg=_rparg,
                           ontime=_ontime,
                           mtime=_mtime,
                           p_start=_p_start,
                           p_end=_p_end)
             # for first create new, nextdtime aouto make by node, put with params
             params['nextdtime'] = _node.nextdtime
     except ValueError:
         loger.error("create node wrong with params: [%s]" % params)
         return 0
     mid = MEETING.new(self.objid, params)
     if mid > 0:
         _node.mid = mid
         Mqueue.auto_node(self.objid, _node)
         if getndtime:
             self.extdata = _node.nextdtime
         return mid
     return 0
Пример #4
0
Mqueue.set_dbwritebacker(None)
Mqueue.set_synctime()
# 从数据库加载会议队列到内存
for m in meeting.load_all_meetings(datetime.today()):
	print(m)
	keys = meeting.key_list
	_mid = m[0]
	_objid = m[1]
	_name = m[2]
	_ondate = m[8]
	_ontime = m[9]
	_mtime = m[10]
	_rpmode = m[12]
	_rparg = m[13]
	node = mnode(_mid, _name, rpmode=_rpmode, rparg=_rparg, ondate=_ondate, ontime=_ontime, holdtime=_mtime)
	Mqueue.auto_node(node, _objid)
# 初始化Flask
app = Flask(__name__)
#app.config.from_object(cur_config.fconf)
app.secret_key  = os.environ.get('SECRET_KEY') or 'zxf***YFJEU7#@#1HFEiefj'
app.env = cur_config.conf_server('mode')

#紧急:fake server[临时]
class muser(object):
	store = {}

	@classmethod
	def get(cls, openid, **kwargs):
		if openid in cls.store:
			return cls.store[openid]
		elif 'js_code' in kwargs and 'session_key' in kwargs: