Skip to content

Commit 581a544

Browse files
committed
Published release v1.0
1 parent f1b4007 commit 581a544

2 files changed

Lines changed: 14 additions & 62 deletions

File tree

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Molly - An intensive python package for study-booking system of CDUT Library
1+
# Molly - A powerful intensive python package for study-booking system of CDUT Library
22

3-
**This is one of the projects by Twikor. For more, take a step to my blog [Twikor's (twic.me)](https://twic.me).**
3+
**This is one of the projects by Twikor. It is not unusual for me to have more on my blog [Twikor's (twic.me)](https://twic.me).**
44

55
**Molly** is an open source package for python helping handling with the booking process of CDUT Library's study.
66

@@ -52,6 +52,12 @@ Otherwise, you may need to set `standbyMode` to `True` if you are using it in sc
5252

5353
Initialize the library, including checking connection to the system, loading room information from file and so on.
5454

55+
|Parameter|Type|Default|Example|Detail|
56+
|-|-|-|-|-|
57+
|`ignoreConnectionFault`|bool|False|True|wether exit on connection failure|
58+
59+
Notice that if `standbyMode` is set to `True`, the script will not exit just as `ignoreCoonectionFault = True` will do.
60+
5561
|Return value|Type|Detail
5662
|-|-|-|
5763
|`True`|bool|\|
@@ -105,6 +111,8 @@ Defaultly return the booking information for a given id of a room in json format
105111

106112
|Parameter|Type|Default|Example|Detail|
107113
|-|-|-|-|-|
114+
|`roomId`|int|None|`125`|could be obtained using `getRoomIdByNumber()`|
115+
|`prettified`|bool|`False`|True|whether to use the data to render a user-friendly table in terminal|
108116

109117
Defaultly return the booking information for a given id of a room in json format. If setting parameter 2 to True, it will use terminaltables to render a prettier user interface right in your browser.
110118

@@ -234,4 +242,4 @@ You can make contributions to this project in the following ways.
234242

235243
Thisn project is maintained by twikor at **[Toay laboratory](https://toay.org)**, a place where we enjoy making creative things. We hope the ones who think of themselves useful to a newly-founded non-profit studio for creators, please don't hesitate joining us.
236244

237-
For more information, please have a look at **[this](https://toay.org/about/sigining-up)**.
245+
For more information, please have a look at **[this](https://toay.org/about/signing-up)**.

dinner.py

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
#-*- coding:utf-8 -*-
33

4-
## An one-file python library for study-booking system of CDUT Library.
4+
## An intensive python library for study-booking system of CDUT Library.
55
##
66
## This work is under Toay's PRE-MIT license with extra agreement that:
77
## - to help protecting the server, rate limit must be setted below 1 rps
@@ -45,14 +45,12 @@ def init(ignoreConnectionFault = False):
4545
connectionResult = connection.connect_ex((socketIp, socketPort))
4646

4747
if connectionResult != 0:
48-
if (ignoreConnectionFault == False):
48+
if (ignoreConnectionFault == False or standbyMode != True):
4949
print "remote server could not be connected, script exited :("
5050
connection.close()
5151
sys.exit(0)
5252
else:
53-
if (standbyMode != True):
54-
print "remote server could not be connected :("
55-
53+
print "remote server could not be connected, ignoring :("
5654
connection.close()
5755
excepted = "Exception_RemoteServerUnreachable"
5856
return excepted
@@ -223,43 +221,6 @@ def getUserInfoByCode(code = None, pretiffied = False):
223221
generateTable = AsciiTable(tableData, tableTitle)
224222
return generateTable.table
225223

226-
'''
227-
228-
# function: get the booking info for a specific room
229-
230-
def getRoomBookingInfo(roomId = None, prettified = False):
231-
cookies = getFreshCookie()
232-
if (roomId == None):
233-
print "lacking parameters, function getRoomBookingInfo exited :("
234-
return False
235-
else:
236-
getRoomBookingInfoUrl = socketUrl + "datafeed"
237-
parameters = {'method':'list', 'id':roomId}
238-
getRoomBookingInfoResponse = requests.get(getRoomBookingInfoUrl, params = parameters)
239-
roomBookingInfo = getRoomBookingInfoResponse
240-
roomBookingInfoDict = roomBookingInfo.json()
241-
roomBookingInfoJsonText = json.dumps(roomBookingInfoDict, ensure_ascii = False)
242-
roomBookingInfoDict = json.load(roomBookingInfoDict)
243-
roomBookingEvents = roomBookingInfo['events']
244-
245-
if (prettified == False):
246-
roomBookingTimeList = []
247-
for roomBookingEvent in roomBookingEvents:
248-
roomBookTimeListEntry = {
249-
'start':roomBookingEvent[2],
250-
'end':roomBookingEvent[3]
251-
}
252-
roomBookTimeList.append(roomBookTimeListEntry)
253-
254-
roomBookingTimeListJson = json.dumps(roomBookingTimeList, ensure_ascii = False)
255-
return roomBookingTimeListJson
256-
else:
257-
roomBookingTimeTable = []
258-
bookingEvents = roomBookingInfo['events']
259-
tableData = [['Start', 'End']]
260-
261-
'''
262-
263224
# function: get the detailed booking information for a specific room
264225

265226
def getRoomBookingInfo(roomId = None, prettified = False, detailed = False):
@@ -356,23 +317,6 @@ def getRoomBookingInfo(roomId = None, prettified = False, detailed = False):
356317
generateTable = AsciiTable(tableData, tableTitle)
357318
return generateTable.table
358319

359-
'''
360-
361-
# function: get the detailed booking info for all rooms
362-
363-
def getAllCurrentBookableRoomsInfo():
364-
global kitchens
365-
if (type == None):
366-
print "lacking parameters, function getAllBookingInfo exited :("
367-
return False
368-
else:
369-
allBookingInfo = []
370-
for room in kitchens:
371-
allBookingInfo.append(getBookingInfo(room['roomId']))
372-
return allBookingInfo
373-
374-
'''
375-
376320
# function: book a room using the cookie got freshly
377321

378322
def bookRoom(users = None, roomId = None, beginDay = None, beginTime = None, endDay = None, endTime = None):

0 commit comments

Comments
 (0)