Browse Source

fixes #22 once and for all (hopefully)

master
theycallmemac 3 years ago
parent
commit
6bb879bb80
4 changed files with 41 additions and 20 deletions
  1. +36
    -14
      README.md
  2. +3
    -3
      scripts/now.py
  3. +1
    -1
      scripts/utils.py
  4. +1
    -2
      tests/test_now.py

+ 36
- 14
README.md View File

@@ -7,33 +7,55 @@ This is a command line tool I hope to develop overtime. In time it will be able

Currently the dcurooms script can show you which rooms in the Henry Grattan building and the School of Computing are free and booked currently.

---

### Installation
Clone this repo by running ```git clone https://github.com/theycallmemac/dcurooms.git```.
cd into the clone and run ```python setup.py install``` as root to install.

- #### On your own machine:
- Clone this repo by running:
```git clone https://github.com/theycallmemac/dcurooms.git```
- cd into the clone and run ```python setup.py install``` as root to install.

### Dependencies
- bs4
- MechanicalSoup
- requests
- #### On Redbrick:
- You'll want to log in to:
```your-username@pygmalion.redbrick.dcu.ie```

- Clone this repo into your home directory by running:
```git clone https://github.com/theycallmemac/dcurooms.git ~/```
- cd in the clone and run:
```pip3 install -r requirements.txt```
- After this you can run:
```alias dcurooms="python3 ~/dcurooms/scripts/dcurooms"```
You can run this on your command line, or alternatively add it to ~/.zshrc

---

### Usage
Buildings are referenced using their assigned building letters. The School of Computing is given the letter "L" and the Henry Grattan is given the letter "C". Don't ask me why it's like that, it's a very odd naming convention.

To book L125 in the School of Computing on the 7/2/2018 from 16:00 to 17:00, run ```dcurooms -b L125 7/2/2018 1600 1700```.
- #### Booking
- To book L125 in the School of Computing on the 7/2/2018 from 16:00 to 17:00, run:
```dcurooms -b L125 7/2/2018 1600 1700```.

To book CG04 in the Henry Grattan on the 5/2/2018 from 18:00 to 20:00, run ```dcurooms -b CG04 5/2/2018 1800 2000```.
- To book CG04 in the Henry Grattan on the 5/2/2018 from 18:00 to 20:00, run ```dcurooms -b CG04 5/2/2018 1800 2000```.

To check the current availabilty of labs in the DCU School of Computing run ```dcurooms -nL``` or ```dcurooms --now --computing```.
- #### Now
- To check the current availabilty of labs in the DCU School of Computing run ```dcurooms -nL``` or ```dcurooms --now --computing```.
- To show the rooms which are currently available in the Henry Grattan building run ```dcurooms -anC``` or ```dcurooms --available --now --grattan```.

To show the rooms which are currently available in the Henry Grattan building run ```dcurooms -anC``` or ```dcurooms --available --now --grattan```.
- #### Lookup
- 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 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 -lL 10 4 1300``` or ```dcurooms --lookup --computing 10 4 1300```

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 -lL 10 4 1300``` or ```dcurooms --lookup --computing 10 4 1300```
- To lookup the info of all free rooms in the Henry Grattan building at 16:00 on the Monday of the 21st week of the college year run ```dcurooms -laC 21 1 1600``` or ```dcurooms --lookup --available --grattan 21 4 1600```.

To lookup the info of all free rooms in the Henry Grattan building at 16:00 on the Monday of the 21st week of the college year run ```dcurooms -laC 21 1 1600``` or ```dcurooms --lookup --available --grattan 21 4 1600```.
- #### Help and Version
- For help run ```dcurooms -h``` and for the current version run ```dcurooms --version```.

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

### Dependencies
- bs4
- MechanicalSoup
- requests

+ 3
- 3
scripts/now.py View File

@@ -49,12 +49,12 @@ class Now(object):
print("\033[1;93m{0}\033[00m".format("Outside scheduled timetables. Please try again at 08:00."))
sys.exit()
for k, v in times.items():
if k == self.hour:
time = v
if k == time:
self.hour = v
break
else:
pass
return time
return self.hour

def get_status(self, options, room, status):
if options.available:


+ 1
- 1
scripts/utils.py View File

@@ -49,7 +49,7 @@ def get_current_time(date):
else:
offset = 52 - start
week = week_no + offset - 1
return str(week), str(day + 1), str(hour - 2), str(minute)
return str(week), str(day + 1), str(hour), str(minute)

def get_version_email():
if int(sys.version[0]) < 3:


+ 1
- 2
tests/test_now.py View File

@@ -1,13 +1,12 @@
import unittest
import sys
import datetime
import os
sys.path.append('.')
from scripts.utils import get_current_time
class RequiredTestCase(unittest.TestCase):
def test_time(self):
now = get_current_time(datetime.datetime.now())
hr = int(now[2]) + 2
hr = int(now[2])
mn = int(now[3])
hr_d = datetime.datetime.now().hour
mn_d = datetime.datetime.now().minute


Loading…
Cancel
Save