Merge pull request #20 from Rushilwiz/development

Development
This commit is contained in:
Rushil Umaretiya 2020-06-16 23:45:31 -04:00 committed by GitHub
commit ece8c8e3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 11524 additions and 128 deletions

1
.1.sstern1profile Normal file
View File

@ -0,0 +1 @@
{"username": "eharris1", "is_student": false, "password": "hackgroup1"}

View File

@ -1 +1 @@
{"username": "eharris1", "is_student": false, "password": "hackgroup1"} {"username": "sstern1", "is_student": false, "password": "Riya2011"}

View File

@ -33,10 +33,10 @@ def getStudent(ion_user, password):
def getDB(user, pwd, url): def getDB(user, pwd, url):
""" """
Sends a GET request to url Sends a GET request to url
:param user: username param user: username
:param pwd: password param pwd: password
:param url: URL for request param url: URL for request
:return: json request response return: json request response
""" """
r = requests.get(url=url, auth=(user, pwd)) r = requests.get(url=url, auth=(user, pwd))
print("GET:" + str(r.status_code)) print("GET:" + str(r.status_code))
@ -46,11 +46,11 @@ def getDB(user, pwd, url):
def patchDB(user, pwd, data, url): def patchDB(user, pwd, data, url):
""" """
Sends a PATCH request to url Sends a PATCH request to url
:param user: username param user: username
:param pwd: password param pwd: password
:param url: URL for request param url: URL for request
:param data: data to request param data: data to request
:return: json request response return: json request response
""" """
r = requests.patch(url=url, data=data, auth=(user, pwd)) r = requests.patch(url=url, data=data, auth=(user, pwd))
print("PATCH:" + str(r.status_code)) print("PATCH:" + str(r.status_code))
@ -61,11 +61,11 @@ def patchDB(user, pwd, data, url):
def postDB(user, pwd, data, url): def postDB(user, pwd, data, url):
""" """
Sends a POST request to url Sends a POST request to url
:param user: username param user: username
:param pwd: password param pwd: password
:param url: URL for request param url: URL for request
:param data: data to request param data: data to request
:return: json request response return: json request response
""" """
r = requests.post(url=url, data=data, auth=(user, pwd)) r = requests.post(url=url, data=data, auth=(user, pwd))
print("POST:" + str(r.status_code)) print("POST:" + str(r.status_code))
@ -76,11 +76,11 @@ def postDB(user, pwd, data, url):
def putDB(user, pwd, data, url): def putDB(user, pwd, data, url):
""" """
Sends a PUT request to url Sends a PUT request to url
:param user: username param user: username
:param pwd: password param pwd: password
:param url: URL for request param url: URL for request
:param data: data to request param data: data to request
:return: json request response return: json request response
""" """
r = requests.put(url=url, data=data, auth=(user, pwd)) r = requests.put(url=url, data=data, auth=(user, pwd))
print("PUT:" + str(r.status_code)) print("PUT:" + str(r.status_code))
@ -91,10 +91,10 @@ def putDB(user, pwd, data, url):
def delDB(user, pwd, url): def delDB(user, pwd, url):
""" """
Sends a DELETE request to url Sends a DELETE request to url
:param user: username param user: username
:param pwd: password param pwd: password
:param url: URL for request param url: URL for request
:return: json request response return: json request response
""" """
r = requests.delete(url=url, auth=(user, pwd)) r = requests.delete(url=url, auth=(user, pwd))
print("DELETE:" + str(r.status_code)) print("DELETE:" + str(r.status_code))
@ -109,7 +109,7 @@ def command(command):
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = process.poll() p = process.poll()
output = process.communicate()[0] output = process.communicate()[0]
print(output.decode('utf-8')) # print(output.decode('utf-8'))
return output.decode('utf-8') return output.decode('utf-8')

View File

@ -133,7 +133,7 @@ def command(command):
process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process = subprocess.Popen(ar, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = process.poll() p = process.poll()
output = process.communicate()[1] output = process.communicate()[1]
print(output.decode('utf-8')) # print(output.decode('utf-8'))
#################################################################################################################################### ####################################################################################################################################
@ -566,7 +566,7 @@ class Teacher:
'path': path, 'path': path,
'classes': course['name'], 'classes': course['name'],
'teacher': self.username, 'teacher': self.username,
'due_date': due, 'due_date': str(due),
'owner':self.id 'owner':self.id
} }
postDB(self.username, self.password, ass, 'http://127.0.0.1:8000/api/assignments/') 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) # t.getChanges('2022rkhondak','APLit_eharris1', 10)
''' '''
{
"name": "a",
"due_date": '2020-08-11 16:58:33.383124',
"path": "",
"teacher": ""
}
TO-DO TO-DO
- More checks - More checks
- add students to APLit_eharris1 - add students to APLit_eharris1

View 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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ class Student(models.Model):
class Assignment(models.Model): class Assignment(models.Model):
owner = models.ForeignKey(User, null=True, blank=True, related_name='aowner', on_delete=models.CASCADE) owner = models.ForeignKey(User, null=True, blank=True, related_name='aowner', on_delete=models.CASCADE)
name=models.CharField(max_length=100, primary_key=True) 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.ManyToManyField(DefFiles)
files=models.CharField(max_length=100, default="", blank=True) files=models.CharField(max_length=100, default="", blank=True)
path=models.CharField(max_length=100, default="", blank=True) path=models.CharField(max_length=100, default="", blank=True)

187
bgservice.bgservice.html Normal file
View 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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<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&nbsp;simple&nbsp;background&nbsp;service&nbsp;to&nbsp;log&nbsp;events&nbsp;in&nbsp;a&nbsp;directory,<br>
check&nbsp;for&nbsp;git&nbsp;commands&nbsp;in&nbsp;bash/zsh&nbsp;history,<br>
and&nbsp;check&nbsp;for&nbsp;non-whitelisted&nbsp;files&nbsp;in&nbsp;the&nbsp;watched&nbsp;directory.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<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>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt><a href="#EventHandler">EventHandler</a>(pevent=None,&nbsp;**kargs)<br>
&nbsp;<br>
Custom&nbsp;event&nbsp;handler&nbsp;for&nbsp;watching&nbsp;a&nbsp;SkoolOS&nbsp;work&nbsp;directory<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</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&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_CLOSE_WRITE&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;none</tt></dd></dl>
<dl><dt><a name="EventHandler-process_IN_CREATE"><strong>process_IN_CREATE</strong></a>(self, event)</dt><dd><tt>Generates&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_CREATE&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;none</tt></dd></dl>
<dl><dt><a name="EventHandler-process_IN_DELETE"><strong>process_IN_DELETE</strong></a>(self, event)</dt><dd><tt>Generates&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_DELETE&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;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&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_MOVED_FROM&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;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&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_MOVED_TO&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;none</tt></dd></dl>
<dl><dt><a name="EventHandler-process_IN_OPEN"><strong>process_IN_OPEN</strong></a>(self, event)</dt><dd><tt>Generates&nbsp;an&nbsp;output&nbsp;to&nbsp;record&nbsp;for&nbsp;IN_OPEN&nbsp;events<br>
param&nbsp;event:&nbsp;event&nbsp;automatically&nbsp;passed&nbsp;to&nbsp;function<br>
return:&nbsp;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&nbsp;behave&nbsp;like&nbsp;a&nbsp;functor&nbsp;the&nbsp;object&nbsp;must&nbsp;be&nbsp;callable.<br>
This&nbsp;method&nbsp;is&nbsp;a&nbsp;dispatch&nbsp;method.&nbsp;Its&nbsp;lookup&nbsp;order&nbsp;is:<br>
&nbsp;&nbsp;1.&nbsp;process_MASKNAME&nbsp;method<br>
&nbsp;&nbsp;2.&nbsp;process_FAMILY_NAME&nbsp;method<br>
&nbsp;&nbsp;3.&nbsp;otherwise&nbsp;calls&nbsp;process_default<br>
&nbsp;<br>
@param&nbsp;event:&nbsp;Event&nbsp;to&nbsp;be&nbsp;processed.<br>
@type&nbsp;event:&nbsp;Event&nbsp;object<br>
@return:&nbsp;By&nbsp;convention&nbsp;when&nbsp;used&nbsp;from&nbsp;the&nbsp;<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>&nbsp;class:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;Returning&nbsp;False&nbsp;or&nbsp;None&nbsp;(default&nbsp;value)&nbsp;means&nbsp;keep&nbsp;on<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executing&nbsp;next&nbsp;chained&nbsp;functors&nbsp;(see&nbsp;chain.py&nbsp;example).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;Returning&nbsp;True&nbsp;instead&nbsp;means&nbsp;do&nbsp;not&nbsp;execute&nbsp;next<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processing&nbsp;functions.<br>
@rtype:&nbsp;bool<br>
@raise&nbsp;ProcessEventError:&nbsp;Event&nbsp;object&nbsp;undispatchable,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unknown&nbsp;event.</tt></dd></dl>
<dl><dt><a name="EventHandler-__init__"><strong>__init__</strong></a>(self, pevent=None, **kargs)</dt><dd><tt>Enable&nbsp;chaining&nbsp;of&nbsp;<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>&nbsp;instances.<br>
&nbsp;<br>
@param&nbsp;pevent:&nbsp;Optional&nbsp;callable&nbsp;object,&nbsp;will&nbsp;be&nbsp;called&nbsp;on&nbsp;event<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processing&nbsp;(before&nbsp;self).<br>
@type&nbsp;pevent:&nbsp;callable<br>
@param&nbsp;kargs:&nbsp;This&nbsp;constructor&nbsp;is&nbsp;implemented&nbsp;as&nbsp;a&nbsp;template&nbsp;method<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegating&nbsp;its&nbsp;optionals&nbsp;keyworded&nbsp;arguments&nbsp;to&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;<a href="#EventHandler-my_init">my_init</a>().<br>
@type&nbsp;kargs:&nbsp;dict</tt></dd></dl>
<dl><dt><a name="EventHandler-my_init"><strong>my_init</strong></a>(self, **kargs)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;called&nbsp;from&nbsp;<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>().&nbsp;This&nbsp;method&nbsp;is<br>
empty&nbsp;here&nbsp;and&nbsp;must&nbsp;be&nbsp;redefined&nbsp;to&nbsp;be&nbsp;useful.&nbsp;In&nbsp;effect,&nbsp;if&nbsp;you<br>
need&nbsp;to&nbsp;specifically&nbsp;initialize&nbsp;your&nbsp;subclass'&nbsp;instance&nbsp;then&nbsp;you<br>
just&nbsp;have&nbsp;to&nbsp;override&nbsp;this&nbsp;method&nbsp;in&nbsp;your&nbsp;subclass.&nbsp;Then&nbsp;all&nbsp;the<br>
keyworded&nbsp;arguments&nbsp;passed&nbsp;to&nbsp;<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>()&nbsp;will&nbsp;be<br>
transmitted&nbsp;as&nbsp;parameters&nbsp;to&nbsp;this&nbsp;method.&nbsp;Beware&nbsp;you&nbsp;MUST&nbsp;pass<br>
keyword&nbsp;arguments&nbsp;though.<br>
&nbsp;<br>
@param&nbsp;kargs:&nbsp;optional&nbsp;delegated&nbsp;arguments&nbsp;from&nbsp;<a href="#EventHandler-__init__">__init__</a>().<br>
@type&nbsp;kargs:&nbsp;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&nbsp;default&nbsp;this&nbsp;method&nbsp;only&nbsp;reports&nbsp;warning&nbsp;messages,&nbsp;you&nbsp;can&nbsp;overredide<br>
it&nbsp;by&nbsp;subclassing&nbsp;<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>&nbsp;and&nbsp;implement&nbsp;your&nbsp;own<br>
process_IN_Q_OVERFLOW&nbsp;method.&nbsp;The&nbsp;actions&nbsp;you&nbsp;can&nbsp;take&nbsp;on&nbsp;receiving&nbsp;this<br>
event&nbsp;is&nbsp;either&nbsp;to&nbsp;update&nbsp;the&nbsp;variable&nbsp;max_queued_events&nbsp;in&nbsp;order&nbsp;to<br>
handle&nbsp;more&nbsp;simultaneous&nbsp;events&nbsp;or&nbsp;to&nbsp;modify&nbsp;your&nbsp;code&nbsp;in&nbsp;order&nbsp;to<br>
accomplish&nbsp;a&nbsp;better&nbsp;filtering&nbsp;diminishing&nbsp;the&nbsp;number&nbsp;of&nbsp;raised&nbsp;events.<br>
Because&nbsp;this&nbsp;method&nbsp;is&nbsp;defined,&nbsp;IN_Q_OVERFLOW&nbsp;will&nbsp;never&nbsp;get<br>
transmitted&nbsp;as&nbsp;arguments&nbsp;to&nbsp;process_default&nbsp;calls.<br>
&nbsp;<br>
@param&nbsp;event:&nbsp;IN_Q_OVERFLOW&nbsp;event.<br>
@type&nbsp;event:&nbsp;dict</tt></dd></dl>
<dl><dt><a name="EventHandler-process_default"><strong>process_default</strong></a>(self, event)</dt><dd><tt>Default&nbsp;processing&nbsp;event&nbsp;method.&nbsp;By&nbsp;default&nbsp;does&nbsp;nothing.&nbsp;Subclass<br>
<a href="pyinotify.html#ProcessEvent">ProcessEvent</a>&nbsp;and&nbsp;redefine&nbsp;this&nbsp;method&nbsp;in&nbsp;order&nbsp;to&nbsp;modify&nbsp;its&nbsp;behavior.<br>
&nbsp;<br>
@param&nbsp;event:&nbsp;Event&nbsp;to&nbsp;be&nbsp;processed.&nbsp;Can&nbsp;be&nbsp;of&nbsp;any&nbsp;type&nbsp;of&nbsp;events&nbsp;but<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IN_Q_OVERFLOW&nbsp;events&nbsp;(see&nbsp;method&nbsp;process_IN_Q_OVERFLOW).<br>
@type&nbsp;event:&nbsp;Event&nbsp;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&nbsp;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&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-stop_watching"><strong>stop_watching</strong></a>()</dt><dd><tt>Stops&nbsp;the&nbsp;watch&nbsp;started&nbsp;by&nbsp;<a href="#-watch_dir">watch_dir</a>()<br>
return:&nbsp;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&nbsp;the&nbsp;specified&nbsp;directory&nbsp;for&nbsp;changes&nbsp;and&nbsp;outputs&nbsp;it&nbsp;in<br>
human&nbsp;readable&nbsp;format&nbsp;to&nbsp;a&nbsp;log&nbsp;file&nbsp;in&nbsp;the&nbsp;specified&nbsp;log&nbsp;directory.<br>
param&nbsp;watched_dir:&nbsp;directory&nbsp;to&nbsp;watch&nbsp;for&nbsp;changes<br>
param&nbsp;log_dir:&nbsp;directory&nbsp;to&nbsp;store&nbsp;log&nbsp;files<br>
return:&nbsp;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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>DIR</strong> = None<br>
<strong>NOTIFIER</strong> = None<br>
<strong>START_TIME</strong> = None<br>
<strong>STDOUT</strong> = &lt;_io.TextIOWrapper name='&lt;stdout&gt;' mode='w' encoding='utf-8'&gt;</td></tr></table>
</body></html>

44
bgservice.checker.html Normal file
View 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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-file_check"><strong>file_check</strong></a>(dir_)</dt><dd><tt>Checks&nbsp;specified&nbsp;dir_&nbsp;for&nbsp;non-whitelisted&nbsp;files&nbsp;using&nbsp;<a href="#-verify_file">verify_file</a>()<br>
param&nbsp;dir_:&nbsp;directory&nbsp;to&nbsp;check<br>
return:&nbsp;list&nbsp;of&nbsp;suspicious&nbsp;files</tt></dd></dl>
<dl><dt><a name="-shell_check"><strong>shell_check</strong></a>()</dt><dd><tt>Check&nbsp;.bash_history&nbsp;and&nbsp;.histfile&nbsp;for&nbsp;git&nbsp;commands&nbsp;that&nbsp;could&nbsp;interfere&nbsp;with&nbsp;SkoolOS<br>
return:&nbsp;results&nbsp;of&nbsp;the&nbsp;check</tt></dd></dl>
<dl><dt><a name="-verify_file"><strong>verify_file</strong></a>(file_)</dt><dd><tt>Check&nbsp;if&nbsp;the&nbsp;file&nbsp;name&nbsp;has&nbsp;an&nbsp;extension&nbsp;in&nbsp;the&nbsp;list&nbsp;of&nbsp;whitelisted&nbsp;file&nbsp;exentsions<br>
param&nbsp;file_:&nbsp;path&nbsp;to&nbsp;file<br>
return:&nbsp;whether&nbsp;or&nbsp;not&nbsp;the&nbsp;file's&nbsp;extension&nbsp;is&nbsp;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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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
View 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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>

View File

@ -7,11 +7,14 @@ import time
import sys import sys
import os import os
import pyinotify import pyinotify
import checker from . import checker
from pathlib import Path from pathlib import Path
class EventHandler(pyinotify.ProcessEvent): class EventHandler(pyinotify.ProcessEvent):
"""
Custom event handler for watching a SkoolOS work directory
"""
_methods = [ _methods = [
"IN_CREATE", "IN_CREATE",
"IN_CLOSE_WRITE", "IN_CLOSE_WRITE",
@ -24,8 +27,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event): def process_IN_CREATE(self, event):
""" """
Generates an output to record for IN_CREATE events Generates an output to record for IN_CREATE events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Created file\n" \ "Event: Created file\n" \
@ -39,8 +42,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_CLOSE_WRITE(self, event): def process_IN_CLOSE_WRITE(self, event):
""" """
Generates an output to record for IN_CLOSE_WRITE events Generates an output to record for IN_CLOSE_WRITE events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Wrote to a file\n" \ "Event: Wrote to a file\n" \
@ -54,8 +57,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_DELETE(self, event): def process_IN_DELETE(self, event):
""" """
Generates an output to record for IN_DELETE events Generates an output to record for IN_DELETE events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Deleted file\n" \ "Event: Deleted file\n" \
@ -69,8 +72,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_MOVED_TO(self, event): def process_IN_MOVED_TO(self, event):
""" """
Generates an output to record for IN_MOVED_TO events Generates an output to record for IN_MOVED_TO events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Moved a file in\n" \ "Event: Moved a file in\n" \
@ -84,8 +87,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_MOVED_FROM(self, event): def process_IN_MOVED_FROM(self, event):
""" """
Generates an output to record for IN_MOVED_FROM events Generates an output to record for IN_MOVED_FROM events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Moved a file out\n" \ "Event: Moved a file out\n" \
@ -99,8 +102,8 @@ class EventHandler(pyinotify.ProcessEvent):
def process_IN_OPEN(self, event): def process_IN_OPEN(self, event):
""" """
Generates an output to record for IN_OPEN events Generates an output to record for IN_OPEN events
:param event: event automatically passed to function param event: event automatically passed to function
:return: none return: none
""" """
description = \ description = \
"Event: Opened file\n" \ "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 Watches the specified directory for changes and outputs it in
human readable format to a log file in the specified log directory. human readable format to a log file in the specified log directory.
:param watched_dir: directory to watch for changes param watched_dir: directory to watch for changes
:param log_dir: directory to store log files param log_dir: directory to store log files
:return: none return: none
""" """
global DIR global DIR
global START_TIME global START_TIME
@ -132,9 +135,10 @@ def watch_dir(watched_dir=str(Path.home()), log_dir="SkoolOS/logs"):
DIR = watched_dir DIR = watched_dir
if not os.path.exists(log_dir): if not os.path.exists(log_dir):
os.makedirs(log_dir) os.makedirs(log_dir)
logfile = open( logfile_ = log_dir + "/skooloslog"
log_dir + "/skoolos_" + if os.path.isfile(logfile_):
time.strftime("%m%d%Y-%H%M%S", time.localtime()), 'w') os.remove(logfile_)
logfile = open(logfile_, 'w')
START_TIME = time.time() START_TIME = time.time()
wm = pyinotify.WatchManager() wm = pyinotify.WatchManager()
mask = pyinotify.IN_CREATE | pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE | \ 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(): def stop_watching():
""" """
Stops the watch started by watch_dir() Stops the watch started by watch_dir()
:return: none return: none
""" """
NOTIFIER.stop() NOTIFIER.stop()
now = time.time() now = time.time()

View File

@ -1,3 +0,0 @@
#!/bin/sh
python3 bgservice.py

View File

@ -70,7 +70,7 @@ file_whitelist = [
def shell_check(): def shell_check():
""" """
Check .bash_history and .histfile for git commands that could interfere with SkoolOS 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 = [ bash_history = [
line.strip() line.strip()
@ -93,8 +93,8 @@ def shell_check():
def verify_file(file_): def verify_file(file_):
""" """
Check if the file name has an extension in the list of whitelisted file exentsions Check if the file name has an extension in the list of whitelisted file exentsions
:param file_: path to file param file_: path to file
:return: whether or not the file's extension is whitelisted return: whether or not the file's extension is whitelisted
""" """
for ext in file_whitelist: for ext in file_whitelist:
if len(file_) > len(ext): if len(file_) > len(ext):
@ -106,8 +106,8 @@ def verify_file(file_):
def file_check(dir_): def file_check(dir_):
""" """
Checks specified dir_ for non-whitelisted files using verify_file() Checks specified dir_ for non-whitelisted files using verify_file()
:param dir_: directory to check param dir_: directory to check
:return: list of suspicious files return: list of suspicious files
""" """
files = glob(dir_ + "/**/*", recursive=True) files = glob(dir_ + "/**/*", recursive=True)
suspicious_files = [] suspicious_files = []

View File

@ -1,2 +0,0 @@
import bgservice as bg
bg.watch_dir()

View File

@ -1,4 +0,0 @@
import bgservice as bg
bg.watch_dir()
input()
bg.stop_watching()

View File

@ -1,2 +1,16 @@
Background Service 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).

View File

@ -17,7 +17,6 @@ Enter the valid SkoolOS username and password. Congratialations, you have succes
1. CLI as a teacher: 1. CLI as a teacher:
============ ============
Start the CLI and select your username. For instance, teacher 'eharris1'
.. code-block:: python .. code-block:: python
python skoolos.py python skoolos.py
@ -26,14 +25,14 @@ Start the CLI and select your username. For instance, teacher 'eharris1'
2) eharris1 2) eharris1
3) Make new user 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) ? Select class: (Use arrow keys)
Art12_eharris1 Art12_eharris1
English12_eharris1 English12_eharris1
History12_eharris1 History12_eharris1
Make New Class Make New Class
Exit SkoolOS Exit SkoolOS
Making a new class: 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). 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. 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. 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) ? Select class: (Use arrow keys)
Art12_eharris1 Art12_eharris1
English12_eharris1 English12_eharris1
History12_eharris1 History12_eharris1
Make New Class Make New Class
Exit SkoolOS 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) OR::
1) Add individual student
2) Add list of students through path
3) Exit
? Add Students): 2) Add list of students through path ? Add Students): 1) Add individual student
File must be .txt and have 1 student username per line Student name: 2022rkhondak
Relative Path: students.txt
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 OR
@ -141,13 +222,52 @@ GET:200
? Select new assignment: Assignment1 ? Select new assignment: Assignment1
Enter due date (Example: 2020-08-11 16:58): 2020-08-11 16:58 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.

112
skoolos.html Normal file
View 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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<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&nbsp;main&nbsp;program&nbsp;file&nbsp;for&nbsp;SkoolOS</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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&nbsp;the&nbsp;user&nbsp;via&nbsp;Ion&nbsp;OAuth</tt></dd></dl>
<dl><dt><a name="-chooseClassStudent"><strong>chooseClassStudent</strong></a>(student)</dt><dd><tt>Chooses&nbsp;a&nbsp;class&nbsp;for&nbsp;a&nbsp;student&nbsp;to&nbsp;view&nbsp;and&nbsp;work&nbsp;on<br>
param&nbsp;student:&nbsp;a&nbsp;student<br>
return:&nbsp;a&nbsp;course&nbsp;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&nbsp;students&nbsp;to&nbsp;choose&nbsp;what&nbsp;they&nbsp;want&nbsp;to&nbsp;do&nbsp;related&nbsp;to&nbsp;a&nbsp;class<br>
The&nbsp;student&nbsp;can&nbsp;save,&nbsp;exit,&nbsp;or&nbsp;go&nbsp;back<br>
param&nbsp;student:&nbsp;a&nbsp;student<br>
param&nbsp;course:&nbsp;a&nbsp;course<br>
return:&nbsp;True&nbsp;if&nbsp;exiting,&nbsp;False&nbsp;if&nbsp;going&nbsp;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&nbsp;a&nbsp;simple&nbsp;HTTP&nbsp;server&nbsp;for&nbsp;creating&nbsp;api&nbsp;requests&nbsp;from&nbsp;the&nbsp;CLI</tt></dd></dl>
<dl><dt><a name="-delDB"><strong>delDB</strong></a>(USER, PWD, url)</dt><dd><tt>Sends&nbsp;a&nbsp;DELETE&nbsp;request&nbsp;to&nbsp;url<br>
param&nbsp;USER:&nbsp;username<br>
param&nbsp;PWD:&nbsp;password<br>
param&nbsp;url:&nbsp;URL&nbsp;for&nbsp;request<br>
return:&nbsp;json&nbsp;request&nbsp;response</tt></dd></dl>
<dl><dt><a name="-getDB"><strong>getDB</strong></a>(USER, PWD, url)</dt><dd><tt>Sends&nbsp;a&nbsp;GET&nbsp;request&nbsp;to&nbsp;url<br>
param&nbsp;USER:&nbsp;username<br>
param&nbsp;PWD:&nbsp;password<br>
param&nbsp;url:&nbsp;URL&nbsp;for&nbsp;request<br>
return:&nbsp;json&nbsp;request&nbsp;response</tt></dd></dl>
<dl><dt><a name="-getUser"><strong>getUser</strong></a>(ion_user, password, utype)</dt><dd><tt>Returns&nbsp;user&nbsp;information<br>
param&nbsp;ion_user:&nbsp;user<br>
param&nbsp;password:&nbsp;user's&nbsp;password<br>
param&nbsp;utype:&nbsp;type&nbsp;of&nbsp;user&nbsp;(student&nbsp;or&nbsp;teacher<br>
return:&nbsp;api&nbsp;user&nbsp;information</tt></dd></dl>
<dl><dt><a name="-main"><strong>main</strong></a>()</dt><dd><tt>The&nbsp;Command&nbsp;Line&nbsp;Interface&nbsp;(CLI)&nbsp;for&nbsp;SkoolOS<br>
Serves&nbsp;to&nbsp;allow&nbsp;both&nbsp;teachers&nbsp;and&nbsp;students&nbsp;to&nbsp;access&nbsp;the&nbsp;majority&nbsp;of&nbsp;the&nbsp;features&nbsp;of&nbsp;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&nbsp;the&nbsp;user&nbsp;to&nbsp;create&nbsp;a&nbsp;password<br>
return:&nbsp;the&nbsp;password</tt></dd></dl>
<dl><dt><a name="-patchDB"><strong>patchDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends&nbsp;a&nbsp;PATCH&nbsp;request&nbsp;to&nbsp;url<br>
param&nbsp;USER:&nbsp;username<br>
param&nbsp;PWD:&nbsp;password<br>
param&nbsp;url:&nbsp;URL&nbsp;for&nbsp;request<br>
param&nbsp;data:&nbsp;data&nbsp;to&nbsp;request<br>
return:&nbsp;json&nbsp;request&nbsp;response</tt></dd></dl>
<dl><dt><a name="-postDB"><strong>postDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends&nbsp;a&nbsp;POST&nbsp;request&nbsp;to&nbsp;url<br>
param&nbsp;USER:&nbsp;username<br>
param&nbsp;PWD:&nbsp;password<br>
param&nbsp;url:&nbsp;URL&nbsp;for&nbsp;request<br>
param&nbsp;data:&nbsp;data&nbsp;to&nbsp;request<br>
return:&nbsp;json&nbsp;request&nbsp;response</tt></dd></dl>
<dl><dt><a name="-putDB"><strong>putDB</strong></a>(USER, PWD, url, data)</dt><dd><tt>Sends&nbsp;a&nbsp;PUT&nbsp;request&nbsp;to&nbsp;url<br>
param&nbsp;USER:&nbsp;username<br>
param&nbsp;PWD:&nbsp;password<br>
param&nbsp;url:&nbsp;URL&nbsp;for&nbsp;request<br>
param&nbsp;data:&nbsp;data&nbsp;to&nbsp;request<br>
return:&nbsp;json&nbsp;request&nbsp;response</tt></dd></dl>
<dl><dt><a name="-studentCLI"><strong>studentCLI</strong></a>(user, password)</dt><dd><tt>The&nbsp;CLI&nbsp;for&nbsp;students&nbsp;to&nbsp;access<br>
param&nbsp;user:&nbsp;student&nbsp;username<br>
param&nbsp;password:&nbsp;student&nbsp;password</tt></dd></dl>
<dl><dt><a name="-teacherCLI"><strong>teacherCLI</strong></a>(user, password)</dt><dd><tt>The&nbsp;CLI&nbsp;for&nbsp;teachers&nbsp;to&nbsp;access<br>
param&nbsp;user:&nbsp;teachers&nbsp;username<br>
param&nbsp;password:&nbsp;teachers&nbsp;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>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>

View File

@ -1,14 +1,13 @@
"""
The main program file for SkoolOS
"""
import sys import sys
from urllib.parse import urlparse from urllib.parse import urlparse
import requests import requests
from requests_oauthlib import OAuth2Session from requests_oauthlib import OAuth2Session
from selenium import webdriver from selenium import webdriver
import os
import os.path import os.path
import time import time
import http.server import http.server
import shutil
import socketserver import socketserver
from threading import Thread from threading import Thread
from werkzeug.urls import url_decode from werkzeug.urls import url_decode
@ -19,6 +18,8 @@ import datetime
import os import os
import argparse import argparse
import webbrowser import webbrowser
#from bgservice import bgservice as bg
import atexit
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6' client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY' client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'
@ -87,18 +88,42 @@ def main():
USER = data['username'] USER = data['username']
print(data['username']) print(data['username'])
if data['is_student']: if data['is_student']:
# empty_logs()
# bg.watch_dir()
studentCLI(USER, PWD) studentCLI(USER, PWD)
atexit.register(stop_bg_service)
else: else:
teacherCLI(USER, PWD) teacherCLI(USER, PWD)
#################################################################################################### STUDENT METHODS #################################################################################################### 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): def studentCLI(user, password):
""" """
The CLI for students to access The CLI for students to access
@param user: student username :param user: student username
@param password: student password :param password: student password
""" """
from CLI import student from CLI import student
data = getUser(user, password, 'student') data = getUser(user, password, 'student')
@ -116,7 +141,7 @@ def studentCLI(user, password):
def chooseClassStudent(student): def chooseClassStudent(student):
""" """
Chooses a class for a student to view and work on Chooses a class for a student to view and work on
@param student: a student :param student: a student
:return: a course prompt :return: a course prompt
""" """
carray = student.sclass.split(",") 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 Allows students to choose what they want to do related to a class
The student can save, exit, or go back The student can save, exit, or go back
@param student: a student :param student: a student
@param course: a course :param course: a course
:return: True if exiting, False if going back :return: True if exiting, False if going back
""" """
student.viewClass(course) student.viewClass(course)
@ -175,14 +200,14 @@ def classOptionsStudent(student, course):
tlist = [] tlist = []
b = True b = True
for a in assignments: for a in assignments:
oname = a + "_" + course oname = a + "_" + course
a = student.username + "/" + a a = student.username + "/" + a
if(os.path.isdir(a) and not "." in a and not oname in student.completed): if(os.path.isdir(a) and not "." in a and not oname in student.completed):
tlist.append(a) tlist.append(a)
assignments = tlist assignments = tlist
assignments.append("Back") assignments.append("Back")
print(assignments) print(assignments)
options = [ options = [
{ {
'type': 'list', 'type': 'list',
@ -203,8 +228,8 @@ def classOptionsStudent(student, course):
def teacherCLI(user, password): def teacherCLI(user, password):
""" """
The CLI for teachers to access The CLI for teachers to access
@param user: teachers username :param user: teachers username
@param password: teachers password :param password: teachers password
""" """
from CLI import teacher from CLI import teacher
data = getUser(user, password, '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) data = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/classes/" + course)
students = data["confirmed"] students = data["confirmed"]
unconf = data['unconfirmed'] unconf = data['unconfirmed']
print("Studented in class: ") print("Students in class: ")
for s in students: for s in students:
print(s) print(s)
print("Requsted Students: ") print("Requsted Students: ")
@ -451,8 +476,15 @@ def viewStudentsTeacher(teacher, course):
s = f.split("_")[0] s = f.split("_")[0]
alist.append(s) alist.append(s)
print("Has submitted: " + str(alist)) print("Has submitted: " + str(alist))
answer = None
#put log stuff 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): def getUser(ion_user, password, utype):
""" """
Returns user information Returns user information
@param ion_user: user :param ion_user: user
@param password: user's password :param password: user's password
@param utype: type of user (student or teacher :param utype: type of user (student or teacher
:return: api user information :return: api user information
""" """
if 'student' in utype: if 'student' in utype:
@ -490,10 +522,10 @@ def getUser(ion_user, password, utype):
def patchDB(USER, PWD, url, data): def patchDB(USER, PWD, url, data):
""" """
Sends a PATCH request to url Sends a PATCH request to url
@param USER: username :param USER: username
@param PWD: password :param PWD: password
@param url: URL for request :param url: URL for request
@param data: data to request :param data: data to request
:return: json request response :return: json request response
""" """
r = requests.patch(url=url, data=data, auth=(USER, PWD)) 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): def getDB(USER, PWD, url):
""" """
Sends a GET request to url Sends a GET request to url
@param USER: username :param USER: username
@param PWD: password :param PWD: password
@param url: URL for request :param url: URL for request
:return: json request response :return: json request response
""" """
r = requests.get(url=url, auth=(USER, PWD)) r = requests.get(url=url, auth=(USER, PWD))
@ -517,10 +549,10 @@ def getDB(USER, PWD, url):
def postDB(USER, PWD, url, data): def postDB(USER, PWD, url, data):
""" """
Sends a POST request to url Sends a POST request to url
@param USER: username :param USER: username
@param PWD: password :param PWD: password
@param url: URL for request :param url: URL for request
@param data: data to request :param data: data to request
:return: json request response :return: json request response
""" """
r = requests.post(url=url, data=data, auth=(USER, PWD)) 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): def putDB(USER, PWD, url, data):
""" """
Sends a PUT request to url Sends a PUT request to url
@param USER: username :param USER: username
@param PWD: password :param PWD: password
@param url: URL for request :param url: URL for request
@param data: data to request :param data: data to request
:return: json request response :return: json request response
""" """
r = requests.put(url=url, data=data, auth=(USER, PWD)) 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): def delDB(USER, PWD, url):
""" """
Sends a DELETE request to url Sends a DELETE request to url
@param USER: username :param USER: username
@param PWD: password :param PWD: password
@param url: URL for request :param url: URL for request
:return: json request response :return: json request response
""" """
r = requests.delete(url=url, auth=(USER, PWD)) r = requests.delete(url=url, auth=(USER, PWD))
@ -610,7 +642,7 @@ def authenticate():
path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-mac') path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-mac')
if(system.lower() == 'linux'): if(system.lower() == 'linux'):
path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-linux') path = os.path.join(os.getcwd(), 'chromedriver', 'chromedriver-linux')
browser = webdriver.Chrome(path) browser = webdriver.Chrome(path)
browser.get("localhost:8000/login") browser.get("localhost:8000/login")

@ -0,0 +1 @@
Subproject commit 4df0d29276f82f25d75cd03e53ca5b754a10db1f

View File

View File

@ -0,0 +1 @@
its hailstone easy