Browse Source

now at v0.3.0 - added new lookup feature.

pull/18/head
theycallmemac 3 years ago
parent
commit
cb64de199b
5 changed files with 86 additions and 10 deletions
  1. +20
    -1
      CHANGELOG.md
  2. +4
    -1
      README.md
  3. +1
    -1
      scripts/dcurooms
  4. +60
    -6
      scripts/dcurooms.py
  5. +1
    -1
      setup.py

+ 20
- 1
CHANGELOG.md View File

@@ -83,7 +83,7 @@ __contributor:__ theycallmemac
- created, just import dcurooms.py script

- scripts/dcurooms.py
- now at v0.2.1 follwoing a number of fixes changes.
- now at v0.2.1 following a number of fixes changes.
- import specific tools rather than entire libraries.
- functions return information ready for concatenation.
- fixed error for wen the hour returned from get_current_time was greater or equal to 23.
@@ -98,3 +98,22 @@ __contributor:__ theycallmemac

---

---

__entry:__ 16-12-2017
__contributor:__ theycallmemac

---
- scripts/dcurooms.py
- now at v0.3.0 due to some minor changes in what the tool can do and it's usage.
- can now look up specific rooms on any given week and timeslot.
- can also lookup a whole builing when provided with this info too.
- the "-f"/"--free" command now replaced with "-a"/"--available" command. This is due to a feature I plan for the next minor update.
- bugs most definitely persist in this new addition. Fixes on the way soon.

- README.md
- added information on the new lookup commands
- changed info on previous commnads listed.

---


+ 4
- 1
README.md View File

@@ -21,7 +21,10 @@ cd into the clone and run ```python setup.py install``` as root to install.
### Usage
To check the current availabilty of labs in the DCU School of Computing run ```dcurooms -nc``` or ```dcurooms --now --computing```.

To show the rooms which are currently free in the Henry Grattan building run ```dcurooms -fnc``` or ```dcurooms --free --now --computing```.
To show the rooms which are currently available in the Henry Grattan building run ```dcurooms -anc``` or ```dcurooms --available --now --computing```.

To display the information of a specific room in the Henry Grattan building at 16:00 on the Monday of the 4th week of the college year run ```dcurooms -l CG05 4 1 1600``` or ```dcurooms --lookup CG05 4 1 1600```.

To look up the info of all rooms in the School of Computing at 13:00 on the Thursday of the 10th week of the college year run ```dcurooms -lc 10 4 1300``` or ```dcurooms --lookup --computing 10 4 1300```.

For help run ```dcurooms -h``` and for the current version run ```dcurooms --version```.

+ 1
- 1
scripts/dcurooms View File

@@ -1,7 +1,7 @@
import dcurooms


__version__ = '0.2.0'
__version__ = '0.3.0'
__author__ = 'theycallmemac'

dcurooms.main()

+ 60
- 6
scripts/dcurooms.py View File

@@ -10,7 +10,7 @@ from requests import get
from bs4 import BeautifulSoup

__author__ = "theycallmemac"
__version__ = '0.2.1'
__version__ = '0.3.0'
__copyright__ = 'Copyright (c) 2017 theycallmemac'
__license__ = 'GPL-3.0'

@@ -55,7 +55,9 @@ def check_room(timetable_url):

def main():
parser = OptionParser(description='Displays and books rooms around the DCU campus via provided timetable/module details', prog='dcurooms', version='%prog ' + __version__, usage='%prog [option]')
parser.add_option("-f", "--free", action="store_true", help="returns only the rooms/labs that are free in a building")
parser.add_option("-a", "--available", action="store_true", help="returns only the rooms/labs that are free in a building")
parser.add_option("-l", "--lookup", action="store_true", help="returns information given a specific room, week, day and hour")

parser.add_option("-n", "--now", action="store_true", help="show the status of each room/lab as it is at the current time of checking")
parser.add_option("-c", "--computing", action="store_true", help="displays the status of the labs in the School of Computing")
parser.add_option("-g", "--grattan", action="store_true", help="displays the status of rooms in the Henry Grattan building")
@@ -93,9 +95,61 @@ def main():
'2200':'29',
'2230':'30'}

c = ['LG25','LG26','LG27','L101','L114','L125','L128']
g = ['CG01', 'CG02','CG03','CG04','CG05','CG06','CG11','CG12','CG20','CG68','C166']

if options.lookup == True:
details = sys.argv[2:]
if len(details) > 5:
sys.exit()
elif options.computing == True:
week = details[0]
day = details[1]
time = details[2]
for k,v in times.items():
if k == time:
time = v
break
else:
pass
for room in c:
timetable, url = build_timetable("GLA." + room, week, day, time)
status = check_room(url)
print(room + ": " + status)
sys.exit()
elif options.grattan == True:
week = details[0]
day = details[1]
time = details[2]
for k,v in times.items():
if k == time:
time = v
break
else:
pass
for room in g:
timetable, url = build_timetable("GLA." + room, week, day, time)
status = check_room(url)
print(room + ": " + status)
sys.exit()
else:
room = details[0]
week = details[1]
day = details[2]
requested_time = details[3]
for k,v in times.items():
if k == requested_time:
requested_time = v
break
else:
pass

timetable, url = build_timetable("GLA." + room, week, day, requested_time)
status = check_room(url)
print(room + ": " + status)
sys.exit()

if options.now == True:
c = ['LG25','LG26','LG27','L101','L114','L125','L128']
g = ['CG01', 'CG02','CG03','CG04','CG05','CG06','CG11','CG12','CG20','CG68','C166']
week, day, hour, minute = get_current_time(datetime.datetime.now())
if int(hour) < 8 or int(hour) >= 23:
print("Outside scheduled timetables. Try again at 08:00.")
@@ -112,7 +166,7 @@ def main():
else:
pass
if options.computing == True:
if options.free == True:
if options.available == True:
for room in c:
timetable, url = build_timetable("GLA." + room, week, day, current_time)
status = check_room(url)
@@ -125,7 +179,7 @@ def main():
print(room + ": " + status)

elif options.grattan == True:
if options.free == True:
if options.available == True:
for room in g:
timetable, url = build_timetable("GLA." + room, week, day, current_time)
status = check_room(url)


+ 1
- 1
setup.py View File

@@ -3,7 +3,7 @@
from setuptools import setup
from setuptools import find_packages
setup(name='dcurooms',
version='0.2.1',
version='0.3.0',
description='Shows room information around the DCU campus',
author='theycallmemac',
url='',


Loading…
Cancel
Save