diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e74cec329116e6f6c90afee6bfb5c0087d9c3af1..518fa9f9d64dfa8f9d20842362fb124a61f0d35b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,10 @@ image: python:3.9-buster before_script: + - apt install -y xvfb libssl-dev firefox-dev firefox-geckodriver openssl + - openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes - pip install -r requirements.txt + # - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' ## ## Run ssh-agent (inside the build environment) @@ -34,7 +37,8 @@ pages: script: - pwd - cd src - - python -m unlearn.tokenpage + - xvfb-run -s "-screen 0 1400x900x24" python -m unlearn.tokenpage +# - python -m unlearn.tokenpage - cd .. - ls - pwd diff --git a/requirements.txt b/requirements.txt index 110fb16e2826d20eeae41d9f5240720650a5e635..f6b7ff73e780b675b3b2321abdd559bbc4028a14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ diskcache selenium auth-code-flow +beautifulsoup4 \ No newline at end of file diff --git a/src/unlearn/api.py b/src/unlearn/api.py deleted file mode 100644 index 100b71685f840c5d0644eeeba735430348fe6a7e..0000000000000000000000000000000000000000 --- a/src/unlearn/api.py +++ /dev/null @@ -1,5 +0,0 @@ -import uvicorn - - -if __name__ == "__main__": - uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/src/unlearn/chromedriver b/src/unlearn/chromedriver deleted file mode 100755 index f0e0dd16802d655372059db019ae945c008d41a4..0000000000000000000000000000000000000000 Binary files a/src/unlearn/chromedriver and /dev/null differ diff --git a/src/unlearn/geckodriver.log b/src/unlearn/geckodriver.log deleted file mode 100644 index 71099cf92180c2b81e688aecd633b84b06fb09a4..0000000000000000000000000000000000000000 --- a/src/unlearn/geckodriver.log +++ /dev/null @@ -1,18 +0,0 @@ -1665440787180 geckodriver INFO Listening on 127.0.0.1:60967 -1665440787706 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "39301" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilek9MuTe" -ATTENTION: default value of option mesa_glthread overridden by environment. -ATTENTION: default value of option mesa_glthread overridden by environment. -ATTENTION: default value of option mesa_glthread overridden by environment. -ATTENTION: default value of option mesa_glthread overridden by environment. -1665440789077 Marionette INFO Marionette enabled -1665440789084 Marionette INFO Listening on port 43913 -Read port: 43913 -WebDriver BiDi listening on ws://127.0.0.1:39301 -1665440789252 RemoteAgent WARN TLS certificate errors will be ignored for this session -console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /tmp/rust_mozprofilek9MuTe/search.json.mozlz4", (void 0))) -Missing chrome or resource URL: resource://gre/modules/UpdateListener.sys.mjs -DevTools listening on ws://127.0.0.1:39301/devtools/browser/16d42f47-0161-4667-b0c7-f9b7f7ee9a13 -Missing chrome or resource URL: resource://gre/modules/UpdateListener.sys.mjs -console.error: "Error during quit-application-granted: [Exception... \"File error: Not found\" nsresult: \"0x80520012 (NS_ERROR_FILE_NOT_FOUND)\" location: \"JS frame :: resource:///modules/BrowserGlue.jsm :: _onQuitApplicationGranted/tasks< :: line 2009\" data: no]" -1665441520882 Marionette INFO Stopped listening on port 43913 -console.warn: TopSitesFeed: Failed to fetch data from Contile server: NetworkError when attempting to fetch resource. diff --git a/src/unlearn/learn_config.py b/src/unlearn/learn_config.py index 35a1960a33719b2eaa6ca3ea44e41014397769d5..66cdaaf2de990bc965f3e3f501b1eafa371597b8 100644 --- a/src/unlearn/learn_config.py +++ b/src/unlearn/learn_config.py @@ -1,3 +1,4 @@ +import requests from urllib.parse import urlparse import json import os @@ -7,6 +8,10 @@ from auth_code_flow import FlowManager from diskcache import Cache from selenium import webdriver from selenium.webdriver.common.by import By +import socketserver +import ssl +import requests +from bs4 import BeautifulSoup def whoami(lc): @@ -125,7 +130,7 @@ class LearnConfig: print("All done!") - def __init__(self, refresh_token=None): + def __init__(self, refresh_token=None, password=None): cc = Cache(directory= os.path.join( os.path.dirname(__file__), "cache") ) # if "refresh_token" in cc: # del cc['refresh_token'] @@ -152,7 +157,7 @@ class LearnConfig: else: if "refresh_token" in cc: - import requests + url = "https://auth.brightspace.com/core/connect/token" print("Getting refresh token using", refresh_token) refresh_token = cc['refresh_token'] @@ -171,7 +176,7 @@ class LearnConfig: break else: # Do oauth2 refreshing... - self._oauth2_refresh() + self._oauth2_refresh(password=password) # s = input("Please give me a refresh token") # cc['refresh_token'] = s # print("Saved refresh token", s) @@ -222,10 +227,7 @@ class LocalListen(Thread): def run(self): # while True: print("hello world") - import http.server - # import ht - import socketserver - import ssl + PORT = 3434 # Handler = http.server.SimpleHTTPRequestHandler with socketserver.TCPServer(("localhost", PORT), S) as httpd: @@ -302,9 +304,7 @@ if __name__ == '__main__': # authorization_path="/oauth", # ) - import requests - import urllib.parse - from bs4 import BeautifulSoup + user = 'tuhe'