Skip to content

Commit

Permalink
- work on py3 conversion
Browse files Browse the repository at this point in the history
- work on ldap3 conversion
- work on function in windows and dev settings conversion
  • Loading branch information
frankyrumple committed Nov 19, 2018
1 parent 3e516c6 commit c64db02
Show file tree
Hide file tree
Showing 11 changed files with 444 additions and 284 deletions.
16 changes: 16 additions & 0 deletions clear_pyc_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

#top = "c:\\python37-32"

top = os.path.dirname(os.path.abspath(__file__))

for root, dirs, files in os.walk(top, topdown=False):
for name in files:
if name.endswith(".pyc") or name.endswith(".pyo"):
print("Removing " + name)
os.remove(os.path.join(root, name))
#for name in dirs:
# os.rmdir(os.path.join(root, name))


#r = input("Done!")
3 changes: 2 additions & 1 deletion modules.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
requests
ldap
ldap3 # python-ldap
paramiko
ecdsa
isodate
pytube
pywinrm
xlrd
psutil
pycryptodome

5 changes: 4 additions & 1 deletion start_smc.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

rem cd server/web2py

python web2py/web2py.py -p 8000 -i "0.0.0.0" -e -s "SMC Server" --minthreads=4 --maxthreads=8 --timeout=60 -K smc --with-scheduler --ssl_certificate="test.crt" --ssl_private_key="test.key"
python2 clear_pyc_files.py


python2 -B web2py/web2py.py -p 8000 -i "0.0.0.0" -e -s "SMC Server" --minthreads=4 --maxthreads=8 --timeout=60 -K smc --with-scheduler --ssl_certificate="test.crt" --ssl_private_key="test.key"
rem # --ca-cert="ca.crt" --nogui -a "<recycle>"
6 changes: 4 additions & 2 deletions web2py/applications/smc/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def refresh_datasets():

db.commit()
succeeded = True
except Exception, e:
except Exception as e:
message += "Error getting datasets: " + str(e)

return dict(succeeded=succeeded, message=message)
Expand Down Expand Up @@ -366,7 +366,7 @@ def reset_smc():
response.flash = "SMC App Reset" + str(ret)

if kill_scheduler.accepted:
#kill_process_videos_schedule_process()
# kill_process_videos_schedule_process()
kill_all_workers()
response.flash = "Scheduler process killed" # + str(ret)

Expand Down Expand Up @@ -406,10 +406,12 @@ def isFFMPEGRunning():
ret = "IS"
return ret


@auth.requires_membership("Administrators")
def ope():
return dict(message="Welcome")


@auth.requires_membership("Administrators")
def laptop_firewall():
return dict(message="Welcome")
4 changes: 2 additions & 2 deletions web2py/applications/smc/controllers/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def find_wamap_videos():
def getURLS(txt):
# Extract the list of urls from the string
ret = []
pat = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
# pat = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
pat = re.compile(
'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
)
Expand All @@ -719,7 +719,7 @@ def getURLS(txt):
def getPDFURLS(txt):
# Extract the list of urls from the string
ret = []
pat = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
# pat = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
pat = re.compile(
'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
)
Expand Down
55 changes: 52 additions & 3 deletions web2py/applications/smc/controllers/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,68 @@
# try something like

#from ednet.ad import AD
#from ednet import Util, SequentialGUID, AppSettings, W2Py, Student
from ednet import Util, SequentialGUID, AppSettings, W2Py, Student
#from ednet import *
from ednet.ad import AD
from ednet.faculty import Faculty
from ednet.util import Util
from ednet.canvas import Canvas
from pytube import YouTube
import os
import ssl

# import ldap
import ldap3

import ldap

import sys


def ad_test():
# ad_pw = AppSettings.GetValue("ad_service_password", "NOT FOUND")
# file_pw = AppSettings.GetValue("file_server_login_pass", "NOT FOUND")
# c = AD.Connect()

# Keep this off - exposes too much
# ld = AD._ldap

# whoami = AD._ldap.extend.standard.who_am_i()

cn_name = "s777777"
dn = "cn=s777777,ou=students,dc=pencol,dc=local"

# r = AD._ldap.search(dn.encode(AD._ad_encoding),
# "(name=" + str(cn_name).encode(AD._ad_encoding) + ")",
# search_scope=ldap3.SUBTREE,
# attributes=['distinguishedName'],
# )
# s = AD._ldap.response
# ret_arr) # ['distinguishedName'])

# ret = AD.VerifyADSettings(False)

# Test - Enable user
disable = AD.DisableUser(dn)
enable = AD.EnableUser(dn)

last_login_time = AD.GetLastLoginTime(dn)

grp_dn = "cn=test_group,OU=StudentGroups,DC=pencol,DC=local"
cg = AD.CreateGroup(grp_dn)

add_to_group = AD.AddUserToGroup(dn, grp_dn)

t_ou_dn = "OU=test_OU,DC=pencol,DC=local"
test_ou = AD.CreateOU(t_ou_dn)


err = AD._errors

# if len(r) != 0 and len(r[0]['attributes']) > 0 and r[0]['attributes']['distinguishedName'] != '':
# ret = r

return locals()

def test():

#db_canvas = current.db_canvas
Expand All @@ -32,6 +80,7 @@ def test():
cache_time = cache.ram("tmptime", lambda:time.ctime(), time_expire=30)
return locals()


def index():

yt = YouTube()
Expand All @@ -50,7 +99,7 @@ def index():

try:
f.download()
except Exception, e:
except Exception as e:
ret += str(e)

#test = {}
Expand Down
13 changes: 8 additions & 5 deletions web2py/applications/smc/models/a_syspath.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Make sure web2py reloads modules
from gluon.custom_import import track_changes
track_changes(True)

# Make sure to add our module path to the syspath for this app so that modules are loaded properly
import os
import sys

spath_imported = False
#spath_imported = False

import_path = os.path.join(request.folder, 'modules')
if import_path not in sys.path:
sys.path.append(import_path)
spath_imported = True
#import_path = os.path.join(request.folder, 'modules')
#if import_path not in sys.path:
# sys.path.append(import_path)
# spath_imported = True
Loading

0 comments on commit c64db02

Please sign in to comment.