generated pydoc documentation

This commit is contained in:
Nathaniel Kenschaft 2020-06-16 22:35:52 -04:00
parent 23eafc04b7
commit 2e44139d80
15 changed files with 11430 additions and 181 deletions

View File

@ -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))

View File

@ -29,9 +29,9 @@ from datetime import datetime
def getTeacher(ion_user, password):
"""
Gets information about a teacher from the api
:param ion_user: a teacher
:param password: the teacher's password
:return: teacher information or error
param ion_user: a teacher
param password: the teacher's password
return: teacher information or error
"""
URL = "http://127.0.0.1:8000/api/teachers/" + ion_user + "/"
r = requests.get(url=URL, auth=(ion_user,password))
@ -53,10 +53,10 @@ def getTeacher(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))
@ -66,11 +66,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))
@ -81,11 +81,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))
@ -96,11 +96,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))
@ -111,10 +111,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))
@ -124,7 +124,7 @@ def delDB(user, pwd, url):
def command(command):
"""
Runs a shell command
:param command: shell command
param command: shell command
"""
ar = []
command = command.split(" ")
@ -145,7 +145,7 @@ class Teacher:
# intitialze fields after GET request
"""
Initializes a Teacher with the data from the api
:param data: api data
param data: api data
"""
self.git = data['git']
self.username = data['ion_user']
@ -178,7 +178,7 @@ class Teacher:
def checkClass(self, path):
"""
Checks if a directory is valid for creating a class
:param path: path to the new class directory
param path: path to the new class directory
"""
cname = path.split("/")
cname = cname[len(cname) - 1]
@ -221,7 +221,7 @@ class Teacher:
def checkInDB(self, path):
"""
Checks if "path" is in the database
:param path: path to directory
param path: path to directory
"""
n = path.split("/")
n = n[len(n) - 1]
@ -234,7 +234,7 @@ class Teacher:
def addClass(self, path):
"""
Creates a class from an existing directory, adding it to the proper git repository and the api
:param path:
param path:
"""
cname = path.split("/")
cname = cname[len(cname) - 1]
@ -276,7 +276,7 @@ class Teacher:
def makeClass(self, cname):
"""
Makes a class with its own new directory
:param cname: name of class
param cname: name of class
"""
# check if class exists
path = self.username + "/" + cname
@ -314,7 +314,7 @@ class Teacher:
def deleteClass(self, path):
"""
Deletes an existing class
:param path: class directory path
param path: class directory path
"""
if not os.path.exists(path):
print(path + " does not exist locally.")
@ -348,8 +348,8 @@ class Teacher:
def isStudent(self, student):
"""
Checks if the student exists
:param student: a student
:return: True if student exists, False otherwise
param student: a student
return: True if student exists, False otherwise
"""
r = requests.get(url="http://127.0.0.1:8000/api/students/" + student + "/",
auth=(self.username, self.password))
@ -360,9 +360,9 @@ class Teacher:
def reqStudent(self, sname, cname):
"""
Request student informatiion from the api
:param sname: student's name
:param cname: class name
:return: True if successful
param sname: student's name
param cname: class name
return: True if successful
"""
if not self.isStudent(sname):
print(sname + " does not exist.")
@ -406,9 +406,9 @@ class Teacher:
def addStudent(self, sname, cname):
"""
Adds a student to a class
:param sname: student name
:param cname: class name
:return:
param sname: student name
param cname: class name
return:
"""
if not self.isStudent(sname):
print(sname + " does not exist.")
@ -476,9 +476,9 @@ class Teacher:
def reqAddStudentList(self, array, cname):
"""
Runs addStudent() on all students in array
:param array: an array of students
:param cname: class name
:return: students that have not confirmed the request
param array: an array of students
param cname: class name
return: students that have not confirmed the request
"""
unconf = []
for i in range(len(array)):
@ -492,10 +492,10 @@ class Teacher:
def addAssignment(self, path, course, due):
"""
Creates an assignment for "course" that is due on "due"
:param path: directory of assignment
:param course: course name
:param due: due date
:return: False if unsuccessful
param path: directory of assignment
param course: course name
param due: due date
return: False if unsuccessful
"""
parts = path.split("/")
aname = parts[len(parts) - 1]
@ -676,9 +676,9 @@ class Teacher:
def getChanges(self, student, course, commits):
"""
Checks for new submissions by a student
:param student: the student
:param course: the course
:param commits: commits the CLI has made for the assignment
param student: the student
param course: the course
param commits: commits the CLI has made for the assignment
"""
course = getDB(self.username, self.password, "http://127.0.0.1:8000/api/classes/" + course + "/")
ar = self.getCommits(student, course['name'], commits)
@ -735,7 +735,7 @@ class Teacher:
def comment(self):
"""
The ultimate form of laughter
:return: pure joy
return: pure joy
"""
print("heheheh")

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

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 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
@ -152,7 +155,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()

View File

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

View File

@ -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 = []

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()

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

@ -50,7 +50,9 @@ def main():
URL = "http://127.0.0.1:8000/api/"
r = requests.get(url=URL)
except:
print("Run Django server on http://127.0.0.1:8000/ before continuing")
print(
"Run Django server on http://127.0.0.1:8000/ before continuing"
)
sys.exit(0)
input("Welcome to SkoolOS. Press any key to create an account")
@ -94,11 +96,12 @@ def main():
#################################################################################################### STUDENT METHODS
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,8 +119,8 @@ def studentCLI(user, password):
def chooseClassStudent(student):
"""
Chooses a class for a student to view and work on
@param student: a student
:return: a course prompt
param student: a student
return: a course prompt
"""
carray = student.sclass.split(",")
if len(carray) == 1 and carray[0] == "":
@ -142,13 +145,13 @@ 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
:return: True if exiting, False if going back
param student: a student
param course: a course
return: True if exiting, False if going back
"""
student.viewClass(course)
student.getAssignments(course, 100)
choices = ["Save","Submit assignment","Back","Exit SkoolOS"]
student.getAssignments(course, 100)
choices = ["Save", "Submit assignment", "Back", "Exit SkoolOS"]
options = [
{
'type': 'list',
@ -170,29 +173,30 @@ def classOptionsStudent(student, course):
student.exitCLI()
# exit cli
return True
if(option == "Submit assignment"):
if (option == "Submit assignment"):
assignments = os.listdir(student.username)
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):
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',
'name': 'submit',
'choices':assignments,
'message': 'Select: ',
},
{
'type': 'list',
'name': 'submit',
'choices': assignments,
'message': 'Select: ',
},
]
ass = prompt(options)['submit']
if(ass == "Back"):
if (ass == "Back"):
return False
else:
student.submit(course, ass)
@ -203,8 +207,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')
@ -278,7 +282,10 @@ def makeClassTeacher(teacher):
cname = prompt(questions)['cname']
teacher.makeClass(cname)
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
soption = [
"1) Add individual student", "2) Add list of students through path",
"3) Exit"
]
questions = [
{
'type': 'list',
@ -307,10 +314,15 @@ def makeClassTeacher(teacher):
def classOptionsTeacher(teacher, course):
print("Class: " + course)
unconf = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['unconfirmed']
unconf = getDB(teacher.username, teacher.password,
"http://localhost:8000/api/classes/" +
course)['unconfirmed']
for s in unconf:
teacher.addStudent(s, course)
options = ['1) Request Student', "2) Add assignment", "3) View student information", "4) Exit"]
options = [
'1) Request Student', "2) Add assignment",
"3) View student information", "4) Exit"
]
questions = [
{
'type': 'list',
@ -324,7 +336,10 @@ def classOptionsTeacher(teacher, course):
def addStudentsTeacher(teacher, course):
soption = ["1) Add individual student", "2) Add list of students through path", "3) Exit"]
soption = [
"1) Add individual student", "2) Add list of students through path",
"3) Exit"
]
questions = [
{
'type': 'list',
@ -369,7 +384,8 @@ def addStudentsTeacher(teacher, course):
def addAssignmentTeacher(teacher, course):
nlist = os.listdir(teacher.username + "/" + course)
alist = getDB(teacher.username, teacher.password, "http://localhost:8000/api/classes/" + course)['assignments']
alist = getDB(teacher.username, teacher.password,
"http://localhost:8000/api/classes/" + course)['assignments']
print(nlist)
tlist = []
b = True
@ -388,8 +404,8 @@ def addAssignmentTeacher(teacher, course):
nlist = tlist
if len(nlist) == 0:
print("No new assignments found")
print(
"To make an assignment: make a subdirectory in the " + course + " folder. Add a file within the new folder")
print("To make an assignment: make a subdirectory in the " + course +
" folder. Add a file within the new folder")
return False
questions = [
{
@ -419,7 +435,8 @@ def addAssignmentTeacher(teacher, course):
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"]
unconf = data['unconfirmed']
print("Studented in class: ")
@ -429,23 +446,25 @@ def viewStudentsTeacher(teacher, course):
for s in unconf:
print(s)
student = input("View student (Enter student's ion username): ")
while((not student in str(data['confirmed'])) and (not student in str(data['unconfirmed']))):
while ((not student in str(data['confirmed']))
and (not student in str(data['unconfirmed']))):
print("Student not affiliated with class")
student = input("View student ('N' to exit): ")
if student == 'N':
return False
sinfo = getDB(teacher.username, teacher.password, "http://127.0.0.1:8000/api/students/" + student + "/")
sinfo = getDB(teacher.username, teacher.password,
"http://127.0.0.1:8000/api/students/" + student + "/")
pprint.pprint(sinfo)
print("Confirmed: " + str(student in str(data['confirmed'])))
if(student in str(data['confirmed'])):
if (student in str(data['confirmed'])):
path = teacher.username + "/Students/" + course + "/" + student
print(student + "'s work: " + path)
fin = sinfo['completed'].split(",")
alist = []
for f in fin:
if(course in f):
if (course in f):
late = teacher.afterSubmit(course, f, student)
if(late):
if (late):
s = f.split("_")[0] + " (LATE)"
else:
s = f.split("_")[0]
@ -454,16 +473,17 @@ def viewStudentsTeacher(teacher, course):
#put log stuff
############################################################################################################################################
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
:return: api user information
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:
URL = "http://127.0.0.1:8000/api/students/" + ion_user + "/"
@ -490,11 +510,11 @@ 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
: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("PATH:" + str(r.status_code))
@ -504,10 +524,10 @@ 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
: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))
@ -517,11 +537,11 @@ 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
: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))
@ -531,11 +551,11 @@ 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
: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))
@ -545,10 +565,10 @@ 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
: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))
@ -558,7 +578,7 @@ def delDB(USER, PWD, url):
def makePass():
"""
Prompts the user to create a password
:return: the password
return: the password
"""
questions = [
{
@ -591,8 +611,11 @@ def authenticate():
"""
Authenticates the user via Ion OAuth
"""
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
authorization_url, state = oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/")
oauth = OAuth2Session(client_id=client_id,
redirect_uri=redirect_uri,
scope=scope)
authorization_url, state = oauth.authorization_url(
"https://ion.tjhsst.edu/oauth/authorize/")
import os
cdir = os.getcwd()
# Linux: chromdriver-linux
@ -603,14 +626,14 @@ def authenticate():
print("Linux")
system = input("Enter OS: ")
while(system.lower() != "linux" and system.lower() != "macos"):
while (system.lower() != "linux" and system.lower() != "macos"):
print("Not valid OS")
system = input("Enter OS: ")
if(system.lower() == 'macos'):
if (system.lower() == 'macos'):
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')
browser = webdriver.Chrome(path)
browser.get("localhost:8000/login")
@ -621,11 +644,13 @@ def authenticate():
url = browser.current_url
gets = url_decode(url.replace("http://localhost:8000/login/?", ""))
while "http://localhost:8000/login/?username=" not in browser.current_url and (
not browser.current_url == "http://localhost:8000/"): # http://localhost:8000/
not browser.current_url
== "http://localhost:8000/"): # http://localhost:8000/
time.sleep(0.25)
url = browser.current_url
gets = url_decode(url.replace("http://localhost:8000/login/?username=", ""))
gets = url_decode(url.replace("http://localhost:8000/login/?username=",
""))
# code = gets.get("code")
# if state == gets.get("state"):
# state = gets.get("state")
@ -654,12 +679,15 @@ def authenticate():
pwd = data['pwd']
user = data['username']
print(r.status_code)
r = requests.get(url="http://localhost:8000/api/students/" + user + "/", auth=(user, pwd))
r = requests.get(url="http://localhost:8000/api/students/" + user + "/",
auth=(user, pwd))
is_student = False
if r.status_code == 200:
is_student = True
print("Welcome, student " + user)
r = requests.get(url="http://localhost:8000/api/students/" + user + "/", auth=(user, pwd))
r = requests.get(url="http://localhost:8000/api/students/" + user +
"/",
auth=(user, pwd))
profile = r.json()
username = profile['ion_user']
grade = profile['grade']
@ -676,7 +704,9 @@ def authenticate():
else:
print("Welcome, teacher " + user)
r = requests.get(url="http://localhost:8000/api/teachers/" + user + "/", auth=(user, pwd))
r = requests.get(url="http://localhost:8000/api/teachers/" + user +
"/",
auth=(user, pwd))
profile = r.json()
username = profile['ion_user']
profile = {