mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-10 23:40:18 -04:00
commit
ece8c8e3ab
1
.1.sstern1profile
Normal file
1
.1.sstern1profile
Normal file
|
@ -0,0 +1 @@
|
|||
{"username": "eharris1", "is_student": false, "password": "hackgroup1"}
|
|
@ -1 +1 @@
|
|||
{"username": "eharris1", "is_student": false, "password": "hackgroup1"}
|
||||
{"username": "sstern1", "is_student": false, "password": "Riya2011"}
|
|
@ -33,10 +33,10 @@ def getStudent(ion_user, password):
|
|||
def getDB(user, pwd, url):
|
||||
"""
|
||||
Sends a GET request to url
|
||||
:param user: username
|
||||
:param pwd: password
|
||||
:param url: URL for request
|
||||
:return: json request response
|
||||
param user: username
|
||||
param pwd: password
|
||||
param url: URL for request
|
||||
return: json request response
|
||||
"""
|
||||
r = requests.get(url=url, auth=(user, pwd))
|
||||
print("GET:" + str(r.status_code))
|
||||
|
@ -46,11 +46,11 @@ def getDB(user, pwd, url):
|
|||
def patchDB(user, pwd, data, url):
|
||||
"""
|
||||
Sends a PATCH request to url
|
||||
:param user: username
|
||||
:param pwd: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
param user: username
|
||||
param pwd: password
|
||||
param url: URL for request
|
||||
param data: data to request
|
||||
return: json request response
|
||||
"""
|
||||
r = requests.patch(url=url, data=data, auth=(user, pwd))
|
||||
print("PATCH:" + str(r.status_code))
|
||||
|
@ -61,11 +61,11 @@ def patchDB(user, pwd, data, url):
|
|||
def postDB(user, pwd, data, url):
|
||||
"""
|
||||
Sends a POST request to url
|
||||
:param user: username
|
||||
:param pwd: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
param user: username
|
||||
param pwd: password
|
||||
param url: URL for request
|
||||
param data: data to request
|
||||
return: json request response
|
||||
"""
|
||||
r = requests.post(url=url, data=data, auth=(user, pwd))
|
||||
print("POST:" + str(r.status_code))
|
||||
|
@ -76,11 +76,11 @@ def postDB(user, pwd, data, url):
|
|||
def putDB(user, pwd, data, url):
|
||||
"""
|
||||
Sends a PUT request to url
|
||||
:param user: username
|
||||
:param pwd: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
param user: username
|
||||
param pwd: password
|
||||
param url: URL for request
|
||||
param data: data to request
|
||||
return: json request response
|
||||
"""
|
||||
r = requests.put(url=url, data=data, auth=(user, pwd))
|
||||
print("PUT:" + str(r.status_code))
|
||||
|
@ -91,10 +91,10 @@ def putDB(user, pwd, data, url):
|
|||
def delDB(user, pwd, url):
|
||||
"""
|
||||
Sends a DELETE request to url
|
||||
:param user: username
|
||||
:param pwd: password
|
||||
:param url: URL for request
|
||||
:return: json request response
|
||||
param user: username
|
||||
param pwd: password
|
||||
param url: URL for request
|
||||
return: json request response
|
||||
"""
|
||||
r = requests.delete(url=url, auth=(user, pwd))
|
||||
print("DELETE:" + str(r.status_code))
|
||||
|
@ -109,7 +109,7 @@ def command(command):
|
|||
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[0]
|
||||
print(output.decode('utf-8'))
|
||||
# print(output.decode('utf-8'))
|
||||
return output.decode('utf-8')
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ def command(command):
|
|||
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = process.poll()
|
||||
output = process.communicate()[1]
|
||||
print(output.decode('utf-8'))
|
||||
# print(output.decode('utf-8'))
|
||||
|
||||
|
||||
####################################################################################################################################
|
||||
|
@ -566,7 +566,7 @@ class Teacher:
|
|||
'path': path,
|
||||
'classes': course['name'],
|
||||
'teacher': self.username,
|
||||
'due_date': due,
|
||||
'due_date': str(due),
|
||||
'owner':self.id
|
||||
}
|
||||
postDB(self.username, self.password, ass, 'http://127.0.0.1:8000/api/assignments/')
|
||||
|
@ -754,6 +754,13 @@ t.addAssignment("eharris1/Truck_eharris1/Assignment1", "Truck_eharris1", '2020-0
|
|||
# t.getChanges('2022rkhondak','APLit_eharris1', 10)
|
||||
|
||||
'''
|
||||
{
|
||||
"name": "a",
|
||||
"due_date": '2020-08-11 16:58:33.383124',
|
||||
"path": "",
|
||||
"teacher": ""
|
||||
}
|
||||
|
||||
TO-DO
|
||||
- More checks
|
||||
- add students to APLit_eharris1
|
||||
|
|
55
SkoolOS/logs/skoolos_06162020-221844
Normal file
55
SkoolOS/logs/skoolos_06162020-221844
Normal file
|
@ -0,0 +1,55 @@
|
|||
Start time: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/run.py
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Created file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice.run.html
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice.run.html
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
wrote bgservice.run.html
|
||||
Event: Wrote to a file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice.run.html
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/test.py
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Created file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc.139630150929712
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc.139630150929712
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Wrote to a file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc.139630150929712
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Moved a file out
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc.139630150929712
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Moved a file in
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/bgservice/__pycache__/test.cpython-38.pyc
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Created file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/SkoolOS/logs/skoolos_06162020-221848
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
||||
Event: Opened file
|
||||
Event Path: /home/nkenschaft/Sysadmin/skoolos/SkoolOS/logs/skoolos_06162020-221848
|
||||
Timestamp: Tuesday, June 16, 2020 22:18:48
|
||||
|
6452
SkoolOS/logs/skoolos_06162020-221848
Normal file
6452
SkoolOS/logs/skoolos_06162020-221848
Normal file
File diff suppressed because it is too large
Load Diff
4352
SkoolOS/logs/skoolos_06162020-222011
Normal file
4352
SkoolOS/logs/skoolos_06162020-222011
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,7 @@ class Student(models.Model):
|
|||
class Assignment(models.Model):
|
||||
owner = models.ForeignKey(User, null=True, blank=True, related_name='aowner', on_delete=models.CASCADE)
|
||||
name=models.CharField(max_length=100, primary_key=True)
|
||||
due_date=models.DateTimeField()
|
||||
due_date=models.CharField(max_length=100, default="", blank=True)
|
||||
# files = models.ManyToManyField(DefFiles)
|
||||
files=models.CharField(max_length=100, default="", blank=True)
|
||||
path=models.CharField(max_length=100, default="", blank=True)
|
||||
|
|
187
bgservice.bgservice.html
Normal file
187
bgservice.bgservice.html
Normal file
|
@ -0,0 +1,187 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module bgservice.bgservice</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="bgservice.html"><font color="#ffffff">bgservice</font></a>.bgservice</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/nkenschaft/Sysadmin/skoolos/bgservice/bgservice.py">/home/nkenschaft/Sysadmin/skoolos/bgservice/bgservice.py</a></font></td></tr></table>
|
||||
<p><tt>A simple background service to log events in a directory,<br>
|
||||
check for git commands in bash/zsh history,<br>
|
||||
and check for non-whitelisted files in the watched directory.</tt></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="bgservice.checker.html">bgservice.checker</a><br>
|
||||
<a href="os.html">os</a><br>
|
||||
</td><td width="25%" valign=top><a href="pyinotify.html">pyinotify</a><br>
|
||||
<a href="sys.html">sys</a><br>
|
||||
</td><td width="25%" valign=top><a href="time.html">time</a><br>
|
||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>(<a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="bgservice.bgservice.html#EventHandler">EventHandler</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="EventHandler">class <strong>EventHandler</strong></a>(<a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt><a href="#EventHandler">EventHandler</a>(pevent=None, **kargs)<br>
|
||||
<br>
|
||||
Custom event handler for watching a SkoolOS work directory<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="bgservice.bgservice.html#EventHandler">EventHandler</a></dd>
|
||||
<dd><a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a></dd>
|
||||
<dd><a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods defined here:<br>
|
||||
<dl><dt><a name="EventHandler-process_IN_CLOSE_WRITE"><strong>process_IN_CLOSE_WRITE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_CLOSE_WRITE events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_CREATE"><strong>process_IN_CREATE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_CREATE events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_DELETE"><strong>process_IN_DELETE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_DELETE events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_MOVED_FROM"><strong>process_IN_MOVED_FROM</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_MOVED_FROM events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_MOVED_TO"><strong>process_IN_MOVED_TO</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_MOVED_TO events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_OPEN"><strong>process_IN_OPEN</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_OPEN events<br>
|
||||
param event: event automatically passed to function<br>
|
||||
return: none</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>:<br>
|
||||
<dl><dt><a name="EventHandler-__call__"><strong>__call__</strong></a>(self, event)</dt><dd><tt>To behave like a functor the object must be callable.<br>
|
||||
This method is a dispatch method. Its lookup order is:<br>
|
||||
1. process_MASKNAME method<br>
|
||||
2. process_FAMILY_NAME method<br>
|
||||
3. otherwise calls process_default<br>
|
||||
<br>
|
||||
@param event: Event to be processed.<br>
|
||||
@type event: Event object<br>
|
||||
@return: By convention when used from the <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> class:<br>
|
||||
- Returning False or None (default value) means keep on<br>
|
||||
executing next chained functors (see chain.py example).<br>
|
||||
- Returning True instead means do not execute next<br>
|
||||
processing functions.<br>
|
||||
@rtype: bool<br>
|
||||
@raise ProcessEventError: Event object undispatchable,<br>
|
||||
unknown event.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-__init__"><strong>__init__</strong></a>(self, pevent=None, **kargs)</dt><dd><tt>Enable chaining of <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> instances.<br>
|
||||
<br>
|
||||
@param pevent: Optional callable object, will be called on event<br>
|
||||
processing (before self).<br>
|
||||
@type pevent: callable<br>
|
||||
@param kargs: This constructor is implemented as a template method<br>
|
||||
delegating its optionals keyworded arguments to the<br>
|
||||
method <a href="#EventHandler-my_init">my_init</a>().<br>
|
||||
@type kargs: dict</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-my_init"><strong>my_init</strong></a>(self, **kargs)</dt><dd><tt>This method is called from <a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>(). This method is<br>
|
||||
empty here and must be redefined to be useful. In effect, if you<br>
|
||||
need to specifically initialize your subclass' instance then you<br>
|
||||
just have to override this method in your subclass. Then all the<br>
|
||||
keyworded arguments passed to <a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>() will be<br>
|
||||
transmitted as parameters to this method. Beware you MUST pass<br>
|
||||
keyword arguments though.<br>
|
||||
<br>
|
||||
@param kargs: optional delegated arguments from <a href="#EventHandler-__init__">__init__</a>().<br>
|
||||
@type kargs: dict</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-nested_pevent"><strong>nested_pevent</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_IN_Q_OVERFLOW"><strong>process_IN_Q_OVERFLOW</strong></a>(self, event)</dt><dd><tt>By default this method only reports warning messages, you can overredide<br>
|
||||
it by subclassing <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> and implement your own<br>
|
||||
process_IN_Q_OVERFLOW method. The actions you can take on receiving this<br>
|
||||
event is either to update the variable max_queued_events in order to<br>
|
||||
handle more simultaneous events or to modify your code in order to<br>
|
||||
accomplish a better filtering diminishing the number of raised events.<br>
|
||||
Because this method is defined, IN_Q_OVERFLOW will never get<br>
|
||||
transmitted as arguments to process_default calls.<br>
|
||||
<br>
|
||||
@param event: IN_Q_OVERFLOW event.<br>
|
||||
@type event: dict</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="EventHandler-process_default"><strong>process_default</strong></a>(self, event)</dt><dd><tt>Default processing event method. By default does nothing. Subclass<br>
|
||||
<a href="pyinotify.html#ProcessEvent">ProcessEvent</a> and redefine this method in order to modify its behavior.<br>
|
||||
<br>
|
||||
@param event: Event to be processed. Can be of any type of events but<br>
|
||||
IN_Q_OVERFLOW events (see method process_IN_Q_OVERFLOW).<br>
|
||||
@type event: Event instance</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data and other attributes inherited from <a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>:<br>
|
||||
<dl><dt><strong>pevent</strong> = None</dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>:<br>
|
||||
<dl><dt><a name="EventHandler-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-stop_watching"><strong>stop_watching</strong></a>()</dt><dd><tt>Stops the watch started by <a href="#-watch_dir">watch_dir</a>()<br>
|
||||
return: none</tt></dd></dl>
|
||||
<dl><dt><a name="-watch_dir"><strong>watch_dir</strong></a>(watched_dir='/home/nkenschaft', log_dir='SkoolOS/logs')</dt><dd><tt>Watches the specified directory for changes and outputs it in<br>
|
||||
human readable format to a log file in the specified log directory.<br>
|
||||
param watched_dir: directory to watch for changes<br>
|
||||
param log_dir: directory to store log files<br>
|
||||
return: none</tt></dd></dl>
|
||||
</td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#55aa55">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><strong>DIR</strong> = None<br>
|
||||
<strong>NOTIFIER</strong> = None<br>
|
||||
<strong>START_TIME</strong> = None<br>
|
||||
<strong>STDOUT</strong> = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'></td></tr></table>
|
||||
</body></html>
|
44
bgservice.checker.html
Normal file
44
bgservice.checker.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module bgservice.checker</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="bgservice.html"><font color="#ffffff">bgservice</font></a>.checker</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/nkenschaft/Sysadmin/skoolos/bgservice/checker.py">/home/nkenschaft/Sysadmin/skoolos/bgservice/checker.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
|
||||
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-file_check"><strong>file_check</strong></a>(dir_)</dt><dd><tt>Checks specified dir_ for non-whitelisted files using <a href="#-verify_file">verify_file</a>()<br>
|
||||
param dir_: directory to check<br>
|
||||
return: list of suspicious files</tt></dd></dl>
|
||||
<dl><dt><a name="-shell_check"><strong>shell_check</strong></a>()</dt><dd><tt>Check .bash_history and .histfile for git commands that could interfere with SkoolOS<br>
|
||||
return: results of the check</tt></dd></dl>
|
||||
<dl><dt><a name="-verify_file"><strong>verify_file</strong></a>(file_)</dt><dd><tt>Check if the file name has an extension in the list of whitelisted file exentsions<br>
|
||||
param file_: path to file<br>
|
||||
return: whether or not the file's extension is whitelisted</tt></dd></dl>
|
||||
</td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#55aa55">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><strong>file_whitelist</strong> = ['.doc', '.docx', '.odt', '.pdf', '.rtf', '.tex', '.txt', '.wpd', '.3g2', '.3gp', '.avi', '.flv', '.h264', '.m4v', '.mkv', '.mov', '.mp4', '.mpg', '.mpeg', '.rm', ...]</td></tr></table>
|
||||
</body></html>
|
23
bgservice.html
Normal file
23
bgservice.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: package bgservice</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>bgservice</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/nkenschaft/Sysadmin/skoolos/bgservice/__init__.py">/home/nkenschaft/Sysadmin/skoolos/bgservice/__init__.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="bgservice.bgservice.html">bgservice</a><br>
|
||||
</td><td width="25%" valign=top><a href="bgservice.checker.html">checker</a><br>
|
||||
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table>
|
||||
</body></html>
|
|
@ -7,11 +7,14 @@ import time
|
|||
import sys
|
||||
import os
|
||||
import pyinotify
|
||||
import checker
|
||||
from . import checker
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class EventHandler(pyinotify.ProcessEvent):
|
||||
"""
|
||||
Custom event handler for watching a SkoolOS work directory
|
||||
"""
|
||||
_methods = [
|
||||
"IN_CREATE",
|
||||
"IN_CLOSE_WRITE",
|
||||
|
@ -24,8 +27,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_CREATE(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_CREATE events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Created file\n" \
|
||||
|
@ -39,8 +42,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_CLOSE_WRITE(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_CLOSE_WRITE events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Wrote to a file\n" \
|
||||
|
@ -54,8 +57,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_DELETE(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_DELETE events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Deleted file\n" \
|
||||
|
@ -69,8 +72,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_MOVED_TO(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_MOVED_TO events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Moved a file in\n" \
|
||||
|
@ -84,8 +87,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_MOVED_FROM(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_MOVED_FROM events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Moved a file out\n" \
|
||||
|
@ -99,8 +102,8 @@ class EventHandler(pyinotify.ProcessEvent):
|
|||
def process_IN_OPEN(self, event):
|
||||
"""
|
||||
Generates an output to record for IN_OPEN events
|
||||
:param event: event automatically passed to function
|
||||
:return: none
|
||||
param event: event automatically passed to function
|
||||
return: none
|
||||
"""
|
||||
description = \
|
||||
"Event: Opened file\n" \
|
||||
|
@ -122,9 +125,9 @@ def watch_dir(watched_dir=str(Path.home()), log_dir="SkoolOS/logs"):
|
|||
"""
|
||||
Watches the specified directory for changes and outputs it in
|
||||
human readable format to a log file in the specified log directory.
|
||||
:param watched_dir: directory to watch for changes
|
||||
:param log_dir: directory to store log files
|
||||
:return: none
|
||||
param watched_dir: directory to watch for changes
|
||||
param log_dir: directory to store log files
|
||||
return: none
|
||||
"""
|
||||
global DIR
|
||||
global START_TIME
|
||||
|
@ -132,9 +135,10 @@ def watch_dir(watched_dir=str(Path.home()), log_dir="SkoolOS/logs"):
|
|||
DIR = watched_dir
|
||||
if not os.path.exists(log_dir):
|
||||
os.makedirs(log_dir)
|
||||
logfile = open(
|
||||
log_dir + "/skoolos_" +
|
||||
time.strftime("%m%d%Y-%H%M%S", time.localtime()), 'w')
|
||||
logfile_ = log_dir + "/skooloslog"
|
||||
if os.path.isfile(logfile_):
|
||||
os.remove(logfile_)
|
||||
logfile = open(logfile_, 'w')
|
||||
START_TIME = time.time()
|
||||
wm = pyinotify.WatchManager()
|
||||
mask = pyinotify.IN_CREATE | pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE | \
|
||||
|
@ -152,7 +156,7 @@ def watch_dir(watched_dir=str(Path.home()), log_dir="SkoolOS/logs"):
|
|||
def stop_watching():
|
||||
"""
|
||||
Stops the watch started by watch_dir()
|
||||
:return: none
|
||||
return: none
|
||||
"""
|
||||
NOTIFIER.stop()
|
||||
now = time.time()
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
python3 bgservice.py
|
|
@ -70,7 +70,7 @@ file_whitelist = [
|
|||
def shell_check():
|
||||
"""
|
||||
Check .bash_history and .histfile for git commands that could interfere with SkoolOS
|
||||
:return: results of the check
|
||||
return: results of the check
|
||||
"""
|
||||
bash_history = [
|
||||
line.strip()
|
||||
|
@ -93,8 +93,8 @@ def shell_check():
|
|||
def verify_file(file_):
|
||||
"""
|
||||
Check if the file name has an extension in the list of whitelisted file exentsions
|
||||
:param file_: path to file
|
||||
:return: whether or not the file's extension is whitelisted
|
||||
param file_: path to file
|
||||
return: whether or not the file's extension is whitelisted
|
||||
"""
|
||||
for ext in file_whitelist:
|
||||
if len(file_) > len(ext):
|
||||
|
@ -106,8 +106,8 @@ def verify_file(file_):
|
|||
def file_check(dir_):
|
||||
"""
|
||||
Checks specified dir_ for non-whitelisted files using verify_file()
|
||||
:param dir_: directory to check
|
||||
:return: list of suspicious files
|
||||
param dir_: directory to check
|
||||
return: list of suspicious files
|
||||
"""
|
||||
files = glob(dir_ + "/**/*", recursive=True)
|
||||
suspicious_files = []
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
import bgservice as bg
|
||||
bg.watch_dir()
|
|
@ -1,4 +0,0 @@
|
|||
import bgservice as bg
|
||||
bg.watch_dir()
|
||||
input()
|
||||
bg.stop_watching()
|
|
@ -1,2 +1,16 @@
|
|||
Background Service
|
||||
=================
|
||||
=================
|
||||
|
||||
This requires no user input. The proper events are
|
||||
called by the main application to log events in the
|
||||
student's work directory. The service records file
|
||||
accesses, editions, deletions, files moved from an
|
||||
outside directory, and file to an outside directory.
|
||||
Additionally, it records any git commands discovered
|
||||
in the student's .bash_history or .histfile (zsh
|
||||
equivalent), as git commands can interfere with the
|
||||
service. It also checks for files that do not have
|
||||
extensions that are whitelisted. The whitelist
|
||||
includes common file extensions such as text files,
|
||||
presentations, and programming file extensions (e.g.
|
||||
.py for python and .class for java).
|
||||
|
|
|
@ -17,7 +17,6 @@ Enter the valid SkoolOS username and password. Congratialations, you have succes
|
|||
1. CLI as a teacher:
|
||||
============
|
||||
|
||||
Start the CLI and select your username. For instance, teacher 'eharris1'
|
||||
|
||||
.. code-block:: python
|
||||
python skoolos.py
|
||||
|
@ -26,14 +25,14 @@ Start the CLI and select your username. For instance, teacher 'eharris1'
|
|||
❯ 2) eharris1
|
||||
3) Make new user
|
||||
|
||||
You will then be given the choice to select an existing class, Make a new class, or exit the CLI:
|
||||
You will then be given the choice to select an existing class, Make a new class, or exit the CLI:::
|
||||
|
||||
? Select class: (Use arrow keys)
|
||||
❯ Art12_eharris1
|
||||
English12_eharris1
|
||||
History12_eharris1
|
||||
Make New Class
|
||||
Exit SkoolOS
|
||||
? Select class: (Use arrow keys)
|
||||
❯ Art12_eharris1
|
||||
English12_eharris1
|
||||
History12_eharris1
|
||||
Make New Class
|
||||
Exit SkoolOS
|
||||
|
||||
Making a new class:
|
||||
-------
|
||||
|
@ -41,23 +40,105 @@ Making a new class:
|
|||
Select 'Make a New Class'. You will then be prompted to enter a class name. The format for every class must be <subject>_<teacher_username> (Example: Art12_eharris1).
|
||||
Enter Period (must be a positive integer). You will then be prompted to add students. If you have a list of students, enter the relative path of a text file with the student usernames.
|
||||
The file must be a .txt file and have one student username per line. If you add an individual student, simply enter their ion username.
|
||||
one username per line.
|
||||
one username per line.::
|
||||
|
||||
? Select class: (Use arrow keys)
|
||||
Art12_eharris1
|
||||
English12_eharris1
|
||||
History12_eharris1
|
||||
❯ Make New Class
|
||||
Exit SkoolOS
|
||||
? Select class: (Use arrow keys)
|
||||
Art12_eharris1
|
||||
English12_eharris1
|
||||
History12_eharris1
|
||||
❯ Make New Class
|
||||
Exit SkoolOS
|
||||
|
||||
? Add Students): (Use arrow keys)
|
||||
❯ 1) Add individual student
|
||||
2) Add list of students through path
|
||||
3) Exit
|
||||
|
||||
? Add Students): 2) Add list of students through path
|
||||
File must be .txt and have 1 student username per line
|
||||
Relative Path: students.txt
|
||||
|
||||
? Add Students): (Use arrow keys)
|
||||
❯ 1) Add individual student
|
||||
2) Add list of students through path
|
||||
3) Exit
|
||||
OR::
|
||||
|
||||
? Add Students): 2) Add list of students through path
|
||||
File must be .txt and have 1 student username per line
|
||||
Relative Path: students.txt
|
||||
? Add Students): 1) Add individual student
|
||||
Student name: 2022rkhondak
|
||||
|
||||
Accessing an existing class
|
||||
=====================
|
||||
|
||||
Once you have created a class, you can then view and modify certain fields. (Open opening a class, any students who have accepted the request will be automatically
|
||||
added you the class.)::
|
||||
|
||||
:
|
||||
? Select class: (Use arrow keys)
|
||||
Art12_eharris1
|
||||
Civ_eharris1
|
||||
❯ English12_eharris1
|
||||
History12_eharris1
|
||||
Random_eharris1
|
||||
Truck_eharris1
|
||||
Make New Class
|
||||
Exit SkoolOS
|
||||
|
||||
Class: English12_eharris1
|
||||
? Select option: (Use arrow keys)
|
||||
❯ 1) Request Student
|
||||
2) Add assignment
|
||||
3) View student information
|
||||
4) Exit
|
||||
|
||||
Requesting Students
|
||||
-------
|
||||
|
||||
Select 'Request Student'. You will then be prompted to add students. If you have a list of students, enter the relative path of a text file with the student usernames.
|
||||
The file must be a .txt file and have one student username per line. If you add an individual student, simply enter their ion username.
|
||||
one username per line.::
|
||||
|
||||
:
|
||||
Class: English12_eharris1
|
||||
? Select option: (Use arrow keys)
|
||||
❯ 1) Request Student
|
||||
2) Add assignment
|
||||
3) View student information
|
||||
4) Exit
|
||||
|
||||
? Add list of students (input path): (Use arrow keys)
|
||||
❯ 1) Add individual student
|
||||
2) Add list of students through path
|
||||
3) Exit
|
||||
|
||||
? Select option: 1) Request Student
|
||||
? Add list of students (input path): 1) Add individual student
|
||||
? Student Name: 2022rkhondak
|
||||
|
||||
OR::
|
||||
|
||||
? Add Students): 2) Add list of students through path
|
||||
File must be .txt and have 1 student username per line
|
||||
Relative Path: students.txt
|
||||
|
||||
Adding an assignment
|
||||
-------
|
||||
|
||||
To add an assignment, make an assginment subdirectory in the corresponding class wiht at least 1 file. Somehting like:
|
||||
|
||||
eharris1/English12_eharris1/Assignment1/instruct.txt
|
||||
|
||||
You must also put a due date in the correct format.
|
||||
|
||||
:
|
||||
? Select new assignment: Assignment1
|
||||
Enter due date (Example: 2020-08-11 16:58): 2020-08-11 16:58
|
||||
|
||||
View student information
|
||||
-------
|
||||
|
||||
You can view certain information of any student requested or confirmed in the given class. Simply select enter their name and see their profile. You are also given the choice
|
||||
to view their logs (files they have saved, written, git commands, and file that dont match the extention whitelist). Note that as a teacher, you can view a student's current
|
||||
work at ANY TIME. Simply go to the 'Students' directory and select the student's directory.
|
||||
|
||||
eharris1/Students/English12_eharris1/2022rkhondak
|
||||
eharris1/Students/English12_eharris1/2023rumareti
|
||||
|
||||
OR
|
||||
|
||||
|
@ -141,13 +222,52 @@ GET:200
|
|||
? Select new assignment: Assignment1
|
||||
Enter due date (Example: 2020-08-11 16:58): 2020-08-11 16:58
|
||||
|
||||
Students in class:
|
||||
2022rkhondak
|
||||
Requsted Students:
|
||||
2023rumareti
|
||||
View student (Enter student's ion username):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2. CLI as a student:
|
||||
============
|
||||
|
||||
As a student, you can edit your work for certain classes and submit assignments. By default, your workr directory (your username) has a single readme. AND IT SHOULD STAY THAT WAY.
|
||||
To make changes to a class, you must first select that class via the CLI.
|
||||
|
||||
::
|
||||
|
||||
Select a class first:
|
||||
? Select class: (Use arrow keys)
|
||||
English12_eharris1
|
||||
Art12_eharris1
|
||||
❯ Random_eharris1
|
||||
Exit SkoolOS
|
||||
|
||||
You can then view the assignments associated with the class. Open you work directory and modify files within your assignments. At any time, you can 'Save' or go 'Back'.
|
||||
When you are ready, you can submit an assignment:
|
||||
|
||||
:
|
||||
|
||||
? Select: (Use arrow keys)
|
||||
Save
|
||||
❯ Submit assignment
|
||||
Back
|
||||
Exit SkoolOS
|
||||
|
||||
? Select: (Use arrow keys)
|
||||
Assignment1
|
||||
❯ Back
|
||||
|
||||
3. Testing:
|
||||
============
|
||||
|
||||
For testing purposes, we recommed having both student and teacher users on the CLI.
|
||||
|
||||
1. Adding students/confiming
|
||||
|
||||
On a teacher user (eharris1), add an student to a given class (English12_eharris1). Then, exit out of the CLI and run skoolos.py again, but select a student account.
|
||||
Selecting a student account should automatically accept the teacher's invitation. You can then begin creating assignments as a teacher. We recommend switching between accounts,
|
||||
modifying assignments on the students end, exiting, then viewing them in the 'Student' directory as a teacher.
|
||||
|
||||
|
||||
|
|
0
eharris1/Truck_eharris1/Assignment1/README.md
Normal file
0
eharris1/Truck_eharris1/Assignment1/README.md
Normal file
112
skoolos.html
Normal file
112
skoolos.html
Normal file
|
@ -0,0 +1,112 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module skoolos</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>skoolos</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/nkenschaft/Sysadmin/skoolos/skoolos.py">/home/nkenschaft/Sysadmin/skoolos/skoolos.py</a></font></td></tr></table>
|
||||
<p><tt>The main program file for SkoolOS</tt></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="argparse.html">argparse</a><br>
|
||||
<a href="datetime.html">datetime</a><br>
|
||||
<a href="http.html">http</a><br>
|
||||
</td><td width="25%" valign=top><a href="json.html">json</a><br>
|
||||
<a href="os.html">os</a><br>
|
||||
<a href="pprint.html">pprint</a><br>
|
||||
</td><td width="25%" valign=top><a href="requests.html">requests</a><br>
|
||||
<a href="socketserver.html">socketserver</a><br>
|
||||
<a href="sys.html">sys</a><br>
|
||||
</td><td width="25%" valign=top><a href="time.html">time</a><br>
|
||||
<a href="webbrowser.html">webbrowser</a><br>
|
||||
<a href="selenium.webdriver.html">selenium.webdriver</a><br>
|
||||
</td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-addAssignmentTeacher"><strong>addAssignmentTeacher</strong></a>(teacher, course)</dt></dl>
|
||||
<dl><dt><a name="-addStudentsTeacher"><strong>addStudentsTeacher</strong></a>(teacher, course)</dt></dl>
|
||||
<dl><dt><a name="-authenticate"><strong>authenticate</strong></a>()</dt><dd><tt>Authenticates the user via Ion OAuth</tt></dd></dl>
|
||||
<dl><dt><a name="-chooseClassStudent"><strong>chooseClassStudent</strong></a>(student)</dt><dd><tt>Chooses a class for a student to view and work on<br>
|
||||
param student: a student<br>
|
||||
return: a course prompt</tt></dd></dl>
|
||||
<dl><dt><a name="-chooseGeneralTeacher"><strong>chooseGeneralTeacher</strong></a>(teacher)</dt></dl>
|
||||
<dl><dt><a name="-classOptionsStudent"><strong>classOptionsStudent</strong></a>(student, course)</dt><dd><tt>Allows students to choose what they want to do related to a class<br>
|
||||
The student can save, exit, or go back<br>
|
||||
param student: a student<br>
|
||||
param course: a course<br>
|
||||
return: True if exiting, False if going back</tt></dd></dl>
|
||||
<dl><dt><a name="-classOptionsTeacher"><strong>classOptionsTeacher</strong></a>(teacher, course)</dt></dl>
|
||||
<dl><dt><a name="-create_server"><strong>create_server</strong></a>()</dt><dd><tt>Creates a simple HTTP server for creating api requests from the CLI</tt></dd></dl>
|
||||
<dl><dt><a name="-delDB"><strong>delDB</strong></a>(USER, PWD, url)</dt><dd><tt>Sends a DELETE request to url<br>
|
||||
param USER: username<br>
|
||||
param PWD: password<br>
|
||||
param url: URL for request<br>
|
||||
return: json request response</tt></dd></dl>
|
||||
<dl><dt><a name="-getDB"><strong>getDB</strong></a>(USER, PWD, url)</dt><dd><tt>Sends a GET request to url<br>
|
||||
param USER: username<br>
|
||||
param PWD: password<br>
|
||||
param url: URL for request<br>
|
||||
return: json request response</tt></dd></dl>
|
||||
<dl><dt><a name="-getUser"><strong>getUser</strong></a>(ion_user, password, utype)</dt><dd><tt>Returns user information<br>
|
||||
param ion_user: user<br>
|
||||
param password: user's password<br>
|
||||
param utype: type of user (student or teacher<br>
|
||||
return: api user information</tt></dd></dl>
|
||||
<dl><dt><a name="-main"><strong>main</strong></a>()</dt><dd><tt>The Command Line Interface (CLI) for SkoolOS<br>
|
||||
Serves to allow both teachers and students to access the majority of the features of SkoolOS</tt></dd></dl>
|
||||
<dl><dt><a name="-makeClassTeacher"><strong>makeClassTeacher</strong></a>(teacher)</dt></dl>
|
||||
<dl><dt><a name="-makePass"><strong>makePass</strong></a>()</dt><dd><tt>Prompts the user to create a password<br>
|
||||
return: the password</tt></dd></dl>
|
||||
<dl><dt><a name="-patchDB"><strong>patchDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends a PATCH request to url<br>
|
||||
param USER: username<br>
|
||||
param PWD: password<br>
|
||||
param url: URL for request<br>
|
||||
param data: data to request<br>
|
||||
return: json request response</tt></dd></dl>
|
||||
<dl><dt><a name="-postDB"><strong>postDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends a POST request to url<br>
|
||||
param USER: username<br>
|
||||
param PWD: password<br>
|
||||
param url: URL for request<br>
|
||||
param data: data to request<br>
|
||||
return: json request response</tt></dd></dl>
|
||||
<dl><dt><a name="-putDB"><strong>putDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends a PUT request to url<br>
|
||||
param USER: username<br>
|
||||
param PWD: password<br>
|
||||
param url: URL for request<br>
|
||||
param data: data to request<br>
|
||||
return: json request response</tt></dd></dl>
|
||||
<dl><dt><a name="-studentCLI"><strong>studentCLI</strong></a>(user, password)</dt><dd><tt>The CLI for students to access<br>
|
||||
param user: student username<br>
|
||||
param password: student password</tt></dd></dl>
|
||||
<dl><dt><a name="-teacherCLI"><strong>teacherCLI</strong></a>(user, password)</dt><dd><tt>The CLI for teachers to access<br>
|
||||
param user: teachers username<br>
|
||||
param password: teachers password</tt></dd></dl>
|
||||
<dl><dt><a name="-viewStudentsTeacher"><strong>viewStudentsTeacher</strong></a>(teacher, course)</dt></dl>
|
||||
</td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#55aa55">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><strong>PWD</strong> = ''<br>
|
||||
<strong>USER</strong> = ''<br>
|
||||
<strong>client_id</strong> = 'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'<br>
|
||||
<strong>client_secret</strong> = '0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2...mOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'<br>
|
||||
<strong>redirect_uri</strong> = 'http://localhost:8000/callback/'<br>
|
||||
<strong>scope</strong> = ['read']<br>
|
||||
<strong>token_url</strong> = 'https://ion.tjhsst.edu/oauth/token/'</td></tr></table>
|
||||
</body></html>
|
106
skoolos.py
106
skoolos.py
|
@ -1,14 +1,13 @@
|
|||
"""
|
||||
The main program file for SkoolOS
|
||||
"""
|
||||
import sys
|
||||
from urllib.parse import urlparse
|
||||
import requests
|
||||
from requests_oauthlib import OAuth2Session
|
||||
from selenium import webdriver
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
import http.server
|
||||
import shutil
|
||||
import socketserver
|
||||
from threading import Thread
|
||||
from werkzeug.urls import url_decode
|
||||
|
@ -19,6 +18,8 @@ import datetime
|
|||
import os
|
||||
import argparse
|
||||
import webbrowser
|
||||
#from bgservice import bgservice as bg
|
||||
import atexit
|
||||
|
||||
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
|
||||
client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'
|
||||
|
@ -87,18 +88,42 @@ def main():
|
|||
USER = data['username']
|
||||
print(data['username'])
|
||||
if data['is_student']:
|
||||
# empty_logs()
|
||||
# bg.watch_dir()
|
||||
studentCLI(USER, PWD)
|
||||
|
||||
atexit.register(stop_bg_service)
|
||||
else:
|
||||
teacherCLI(USER, PWD)
|
||||
|
||||
|
||||
#################################################################################################### STUDENT METHODS
|
||||
|
||||
def stop_bg_service():
|
||||
#bg.stop_watching()
|
||||
cur_path = os.path.dirname(__file__)
|
||||
#newpath = os.path.relpath('bgservice/SkoolOS/logs')
|
||||
|
||||
# def empty_logs():
|
||||
# logs_folder = os.path.dirname(__file__) + 'bgservice/SkoolOS/logs/'
|
||||
# for filename in os.listdir(logs_folder):
|
||||
# file_path = os.path.join(folder, filename)
|
||||
# try:
|
||||
# if os.path.isfile(file_path) or os.path.islink(file_path):
|
||||
# os.unlink(file_path)
|
||||
# elif os.path.isdir(file_path):
|
||||
# shutil.rmtree(file_path)
|
||||
# except Exception as e:
|
||||
# print('Failed to delete %s. Reason: %s' % (file_path, e))
|
||||
|
||||
|
||||
|
||||
|
||||
def studentCLI(user, password):
|
||||
"""
|
||||
The CLI for students to access
|
||||
@param user: student username
|
||||
@param password: student password
|
||||
:param user: student username
|
||||
:param password: student password
|
||||
"""
|
||||
from CLI import student
|
||||
data = getUser(user, password, 'student')
|
||||
|
@ -116,7 +141,7 @@ def studentCLI(user, password):
|
|||
def chooseClassStudent(student):
|
||||
"""
|
||||
Chooses a class for a student to view and work on
|
||||
@param student: a student
|
||||
:param student: a student
|
||||
:return: a course prompt
|
||||
"""
|
||||
carray = student.sclass.split(",")
|
||||
|
@ -142,8 +167,8 @@ def classOptionsStudent(student, course):
|
|||
"""
|
||||
Allows students to choose what they want to do related to a class
|
||||
The student can save, exit, or go back
|
||||
@param student: a student
|
||||
@param course: a course
|
||||
:param student: a student
|
||||
:param course: a course
|
||||
:return: True if exiting, False if going back
|
||||
"""
|
||||
student.viewClass(course)
|
||||
|
@ -175,14 +200,14 @@ def classOptionsStudent(student, course):
|
|||
tlist = []
|
||||
b = True
|
||||
for a in assignments:
|
||||
oname = a + "_" + course
|
||||
oname = a + "_" + course
|
||||
a = student.username + "/" + a
|
||||
if(os.path.isdir(a) and not "." in a and not oname in student.completed):
|
||||
tlist.append(a)
|
||||
assignments = tlist
|
||||
assignments.append("Back")
|
||||
print(assignments)
|
||||
|
||||
|
||||
options = [
|
||||
{
|
||||
'type': 'list',
|
||||
|
@ -203,8 +228,8 @@ def classOptionsStudent(student, course):
|
|||
def teacherCLI(user, password):
|
||||
"""
|
||||
The CLI for teachers to access
|
||||
@param user: teachers username
|
||||
@param password: teachers password
|
||||
:param user: teachers username
|
||||
:param password: teachers password
|
||||
"""
|
||||
from CLI import teacher
|
||||
data = getUser(user, password, 'teacher')
|
||||
|
@ -422,7 +447,7 @@ def viewStudentsTeacher(teacher, course):
|
|||
data = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/classes/" + course)
|
||||
students = data["confirmed"]
|
||||
unconf = data['unconfirmed']
|
||||
print("Studented in class: ")
|
||||
print("Students in class: ")
|
||||
for s in students:
|
||||
print(s)
|
||||
print("Requsted Students: ")
|
||||
|
@ -451,8 +476,15 @@ def viewStudentsTeacher(teacher, course):
|
|||
s = f.split("_")[0]
|
||||
alist.append(s)
|
||||
print("Has submitted: " + str(alist))
|
||||
|
||||
#put log stuff
|
||||
answer = None
|
||||
while answer not in ("yes", "no"):
|
||||
answer = input("Would you like to view the student's logs?: ")
|
||||
if answer == "yes" or answer=="y":
|
||||
print (sinfo['log'])
|
||||
elif answer == "no" or answer=="n":
|
||||
print("OK!")
|
||||
else:
|
||||
print("Please enter yes or no.")
|
||||
|
||||
############################################################################################################################################
|
||||
|
||||
|
@ -460,9 +492,9 @@ def viewStudentsTeacher(teacher, course):
|
|||
def getUser(ion_user, password, utype):
|
||||
"""
|
||||
Returns user information
|
||||
@param ion_user: user
|
||||
@param password: user's password
|
||||
@param utype: type of user (student or teacher
|
||||
:param ion_user: user
|
||||
:param password: user's password
|
||||
:param utype: type of user (student or teacher
|
||||
:return: api user information
|
||||
"""
|
||||
if 'student' in utype:
|
||||
|
@ -490,10 +522,10 @@ def getUser(ion_user, password, utype):
|
|||
def patchDB(USER, PWD, url, data):
|
||||
"""
|
||||
Sends a PATCH request to url
|
||||
@param USER: username
|
||||
@param PWD: password
|
||||
@param url: URL for request
|
||||
@param data: data to request
|
||||
:param USER: username
|
||||
:param PWD: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
"""
|
||||
r = requests.patch(url=url, data=data, auth=(USER, PWD))
|
||||
|
@ -504,9 +536,9 @@ def patchDB(USER, PWD, url, data):
|
|||
def getDB(USER, PWD, url):
|
||||
"""
|
||||
Sends a GET request to url
|
||||
@param USER: username
|
||||
@param PWD: password
|
||||
@param url: URL for request
|
||||
:param USER: username
|
||||
:param PWD: password
|
||||
:param url: URL for request
|
||||
:return: json request response
|
||||
"""
|
||||
r = requests.get(url=url, auth=(USER, PWD))
|
||||
|
@ -517,10 +549,10 @@ def getDB(USER, PWD, url):
|
|||
def postDB(USER, PWD, url, data):
|
||||
"""
|
||||
Sends a POST request to url
|
||||
@param USER: username
|
||||
@param PWD: password
|
||||
@param url: URL for request
|
||||
@param data: data to request
|
||||
:param USER: username
|
||||
:param PWD: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
"""
|
||||
r = requests.post(url=url, data=data, auth=(USER, PWD))
|
||||
|
@ -531,10 +563,10 @@ def postDB(USER, PWD, url, data):
|
|||
def putDB(USER, PWD, url, data):
|
||||
"""
|
||||
Sends a PUT request to url
|
||||
@param USER: username
|
||||
@param PWD: password
|
||||
@param url: URL for request
|
||||
@param data: data to request
|
||||
:param USER: username
|
||||
:param PWD: password
|
||||
:param url: URL for request
|
||||
:param data: data to request
|
||||
:return: json request response
|
||||
"""
|
||||
r = requests.put(url=url, data=data, auth=(USER, PWD))
|
||||
|
@ -545,9 +577,9 @@ def putDB(USER, PWD, url, data):
|
|||
def delDB(USER, PWD, url):
|
||||
"""
|
||||
Sends a DELETE request to url
|
||||
@param USER: username
|
||||
@param PWD: password
|
||||
@param url: URL for request
|
||||
:param USER: username
|
||||
:param PWD: password
|
||||
:param url: URL for request
|
||||
:return: json request response
|
||||
"""
|
||||
r = requests.delete(url=url, auth=(USER, PWD))
|
||||
|
@ -610,7 +642,7 @@ def authenticate():
|
|||
path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-mac')
|
||||
if(system.lower() == 'linux'):
|
||||
path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-linux')
|
||||
|
||||
|
||||
browser = webdriver.Chrome(path)
|
||||
|
||||
browser.get("localhost:8000/login")
|
||||
|
|
1
sstern1/Students/wow4_sstern1/rushilwiz
Submodule
1
sstern1/Students/wow4_sstern1/rushilwiz
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 4df0d29276f82f25d75cd03e53ca5b754a10db1f
|
0
sstern1/wow4_sstern1/Hackathon/fuck.txt
Normal file
0
sstern1/wow4_sstern1/Hackathon/fuck.txt
Normal file
0
sstern1/wow4_sstern1/Hailstone/Driver.java
Normal file
0
sstern1/wow4_sstern1/Hailstone/Driver.java
Normal file
1
sstern1/wow4_sstern1/Hailstone/instructions.txt
Normal file
1
sstern1/wow4_sstern1/Hailstone/instructions.txt
Normal file
|
@ -0,0 +1 @@
|
|||
its hailstone easy
|
Loading…
Reference in New Issue
Block a user