2
程序员文章站
2022-07-15 11:21:09
...
try:
uid = cp.get('user', 'Account')
password = cp.get('user', 'Password')
days_delay = int(cp.get('meeting', 'DaysDelay'))
RoomBeginTimeHour = int(cp.get('meeting', 'RoomBeginTimeHour'))
RoomBeginTimeMinute = int(cp.get('meeting', 'RoomBeginTimeMinute'))
RoomDurationHour = int(cp.get('meeting', 'RoomDurationHour'))
RoomDurationMinute = int(cp.get('meeting', 'RoomDurationMinute'))
except ConfigParser.NoOptionError as e:
logger.error('read ini error')
logger.error(e)
sys.exit(-1)
return
if __name__ == '__main__':
logger = logging.getLogger('meeting_room')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler('/home/birthday/pyfile1/meeting_room_logs.log')
fh.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
session = w3_login(uid, password)
for Count in range(len(RoomSearchKeyLst)*2):
RoomSearchKey=RoomSearchKeyLst[int(Count/2)]
if (Count%2) == 0:
RoomBeginTimeHour=9
else:RoomBeginTimeHour=14
logger.info('This is %d time search %s,BeginTime %d, Duration %d ' % (
Count, RoomSearchKey, RoomBeginTimeHour, RoomDurationHour))
meeting_room_id = get_available_room(session)
if meeting_room_id == -1:
logger.info('Conference %s begin %d, Duration 4 is unavailable ' %(RoomSearchKey,RoomBeginTimeHour))
continue
room_detail_url = 'http://imeeting.huawei.com/ResourceInosculate/GetMeetingRoomDetail'
post_dict = {
'roomId': meeting_room_id
}
post_data = urllib.parse.urlencode(post_dict).encode(encoding='UTF8')
req = urllib.request.Request(url=room_detail_url, data=post_data, headers=g_ua)
response = session.open(req)
g_RoomData = json.loads(response.read())
# pprint(g_RoomData)
logger.info('target meeting room: ' + g_RoomData['MeetingRoomData']['RoomName'])
# -----------
room_sche_url = 'http://imeeting.huawei.com/ResourceInosculate/ScheduleCreate'
json_dict = {
"ApproveCycle": g_RoomData['MeetingRoomData']['RoomApproveCycle'],
"ApproveCycleID": g_RoomData['MeetingRoomData']['RoomAdminApproveID'],
"ApproveSingle": g_RoomData['MeetingRoomData']['RoomApproveSingle'],
"ApproveSingleID": "",
"IsVirtualRoom": 'false',
"RoomApproveStatus": 1,
"RoomDescription": g_RoomData['MeetingRoomData']['RoomDescription'],
"MeetingTime": get_meeting_time(),
"RoomID": g_RoomData['MeetingRoomData']['RoomID'],
"RoomName": g_RoomData['MeetingRoomData']['RoomName'],
"RoomRegion": "",
"RoomScheduleID": 0,
"RoomSubHost": "",
"RoomTVTerminalNo": "",
"ADAccount": "",
"SerialNo": Count
}
post_dict = {
'UserTimeZone': '480',
'UserTimeZoneName': '(UTC+08:00)Beijing',
'UserRegionFirstLayer': 2,
'UserRegionSecondLayer': 3,
'UserRegionThirdLayer': -1,
'userMeetingType': '',
'UserSearchType': '',
'UserMyfavoriteName': '',
'ConferenceTopic': '',
'RoomState': '',
'MeetingToVoice': 0,
'rdoVoiceMeetingTime': 0,
'ddlRoomTimeZone': '63/480',
'txtRoomDate': get_meeting_date(days_delay), # 预定时间,Web提交值为“2016-02-07 周日”,经验证可以只提供日期
'ddlRoomBeginTimeHour': RoomBeginTimeHour, # 开始时间-时
'ddlRoomBeginTimeMinute': RoomBeginTimeMinute,
'ddlRoomDurationHour': RoomDurationHour,
'ddlRoomDurationMinute': RoomDurationMinute,
'rdoRoomRepeatSelect': 4,
'ddlRoomSelectDayFirst': 7,
'ddlRoomSelectWeekFirst': 1,
'ckSunday': 0,
'ckMonday': 0,
'ckTuesday': 0,
'ckWendnesday': 0,
'ckThurday': 0,
'ckFriday': 0,
'ckStaday': 0,
'ddlRoomSelectNumMonthFirst': 1,
'ddlRoomSelectWeekMonthFirst': 0,
'txtUserDefined': get_txtUserDefined(), # 经验证,此值不影响预定
'txtRoomEndDateRepeat': get_txtRoomEndDateRepeat(), # 经验证,此值不影响预定
'txtRoomTopic': '预定会议',
'txtOutSideConvener': creater,
'MeetingTopic[0].AgendaOrder': 0,
'MeetingTopic[0].AgendaContentType': 1,
'MeetingTopic[0].AgendaTopic': '',
'MeetingTopic[0].AgendaDuration': '',
'MeetingTopic[1].AgendaOrder': 1,
'MeetingTopic[1].AgendaContentType': 1,
'MeetingTopic[1].AgendaTopic': '',
'MeetingTopic[1].AgendaDuration': '',
'MeetingTopic[2].AgendaOrder': 2,
'MeetingTopic[2].AgendaContentType': 1,
'MeetingTopic[2].AgendaTopic': '',
'MeetingTopic[2].AgendaDuration': '',
'MeetingTopic[3].AgendaOrder': 3,
'MeetingTopic[3].AgendaContentType': 1,
'MeetingTopic[3].AgendaTopic': '',
'MeetingTopic[3].AgendaDuration': '',
'txtVoiceCallers': 0,
'SearchType': 1,
'SearchAll': RoomSearchKey,
'SearchCollection': '点击输入收藏会场名关键字搜索',
'hdMeetingRoomType': 'MeetingRoom',
'hdVoiceType': '',
'hdVideoType': '',
'hdServerTime': '',
'hdSelectedResource': json.dumps(json_dict),
'hdVoiceTypeSelect': 'Common',
'MeetingOperateBy': uid,
'MeetingClientPwd': '0973E2839D96D4182DCFCA498A2467D0',
'Creator': creater,
'hiddenRoomZone': '(UTC+08:00)Beijing',
'hiddenRoomZoneValue': '63/480',
'hdLanguageType': 'ZhCn',
'IsCycleMeetingRole': '0',
'isClickTile': '0',
'selectDate': '',
'hdCycleDateList': '',
'hdRoomid': g_RoomData['MeetingRoomData']['RoomID']
}
# print(post_dict)
# print(json_dict)
post_data = urllib.parse.urlencode(post_dict).encode(encoding='UTF8')
req = urllib.request.Request(url=room_sche_url, data=post_data, headers=g_ua)
response = session.open(req)
result = json.loads(response.read())
#print(result)
# logger.info(result['Code'])
if result['Code'] == 4000:
logger.info('Conference %s begin %d booking 4h success'%(g_RoomData['MeetingRoomData']['RoomName'],RoomBeginTimeHour))
else:
logger.info('Conference %s begin %d booking 4h fail'%(g_RoomData['MeetingRoomData']['RoomName'],RoomBeginTimeHour))
time.sleep(7)
sys.exit(0)