JoostSijm 4 жил өмнө
parent
commit
b768d99cde
3 өөрчлөгдсөн 53 нэмэгдсэн , 10 устгасан
  1. 1 0
      Pipfile
  2. 36 4
      Pipfile.lock
  3. 16 6
      app/__init__.py

+ 1 - 0
Pipfile

@@ -12,6 +12,7 @@ sqlalchemy = "*"
 psycopg2-binary = "*"
 python-dotenv = "*"
 apscheduler = "*"
+rival-regions-wrapper = {editable = true,git = "https://github.com/jjoo914/rival_regions_wrapper"}
 
 [requires]
 python_version = "3"

+ 36 - 4
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "dfc866db4a7e79933532497f154755e037f8ef5947733a821745397d78893acf"
+            "sha256": "5ca54126317baab96d8e152309d0851a7b6333605525e482a74507e84a44392b"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -16,6 +16,13 @@
         ]
     },
     "default": {
+        "appdirs": {
+            "hashes": [
+                "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92",
+                "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"
+            ],
+            "version": "==1.4.3"
+        },
         "apscheduler": {
             "hashes": [
                 "sha256:3bb5229eed6fbbdafc13ce962712ae66e175aa214c69bed35a06bffcf0c5e244",
@@ -40,6 +47,13 @@
             ],
             "version": "==2020.4.5.1"
         },
+        "cfscrape": {
+            "hashes": [
+                "sha256:7c5ef94554e0d6ee7de7cd0d42051526e716ce6c0357679ee0b82c49e189e2ef",
+                "sha256:c62085b42822e196907196f6a09561ec6b2aea8bd87e5a6f84d382e60dd23fe4"
+            ],
+            "version": "==2.1.1"
+        },
         "chardet": {
             "hashes": [
                 "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
@@ -113,6 +127,18 @@
             "index": "pypi",
             "version": "==2.23.0"
         },
+        "rival-regions-wrapper": {
+            "editable": true,
+            "git": "https://github.com/jjoo914/rival_regions_wrapper",
+            "ref": "01b7f73bde05542694874a0b60561e87cbc76be9"
+        },
+        "selenium": {
+            "hashes": [
+                "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c",
+                "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d"
+            ],
+            "version": "==3.141.0"
+        },
         "six": {
             "hashes": [
                 "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
@@ -154,10 +180,10 @@
         },
         "tzlocal": {
             "hashes": [
-                "sha256:11c9f16e0a633b4b60e1eede97d8a46340d042e67b670b290ca526576e039048",
-                "sha256:949b9dd5ba4be17190a80c0268167d7e6c92c62b30026cf9764caf3e308e5590"
+                "sha256:643c97c5294aedc737780a49d9df30889321cbe1204eac2c2ec6134035a92e44",
+                "sha256:e2cb6c6b5b604af38597403e9852872d7f534962ae2954c7f35efcb1ccacf4a4"
             ],
-            "version": "==2.0.0"
+            "version": "==2.1"
         },
         "urllib3": {
             "hashes": [
@@ -165,6 +191,12 @@
                 "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
             ],
             "version": "==1.25.9"
+        },
+        "webbot": {
+            "hashes": [
+                "sha256:8dfe41f5ef1840c6ffe80ca12365bb67a4c2090a8bef238d88f642f54a1bc418"
+            ],
+            "version": "==0.1.4"
         }
     },
     "develop": {}

+ 16 - 6
app/__init__.py

@@ -7,7 +7,7 @@ from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker
 from dotenv import load_dotenv
 from apscheduler.schedulers.background import BackgroundScheduler
-from rival_regions_wrapper import RemoteAuthentication
+from rival_regions_wrapper.rival_regions_wrapper import LocalAuthentication, RemoteAuthentication
 
 
 load_dotenv()
@@ -48,8 +48,18 @@ LOGGER.addHandler(FILE_HANDLER)
 SCHEDULER_LOGGER.addHandler(STREAM_HANDLER)
 SCHEDULER_LOGGER.addHandler(FILE_HANDLER)
 
-# api
-MIDDLEWARE = RemoteAuthentication(
-    os.environ["API_URL"],
-    os.environ["AUTHORIZATION"]
-)
+USERNAME = os.environ.get('username', None)
+PASSWORD = os.environ.get('password', None)
+LOGIN_METHOD = os.environ.get('login_method', None)
+
+class MissingEnvironError(Exception):
+    """Error for missing environ"""
+
+if None in (USERNAME, PASSWORD, LOGIN_METHOD):
+    raise MissingEnvironError(
+        'Load the following variables in your user environment:'
+        'username, password, login_method'
+    )
+
+MIDDLEWARE = LocalAuthentication(USERNAME, PASSWORD, LOGIN_METHOD)
+# MIDDLEWARE = RemoteAuthentication(os.environ["API_URL"], os.environ["AUTHORIZATION"])