Browse Source

Added Dropbox, settings loading

master
Macoy Madson 2 years ago
parent
commit
b1aae7d29f
6 changed files with 67 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +3
    -0
      .gitmodules
  3. +46
    -0
      HomeLifeDisplay.py
  4. +11
    -0
      ReadMe.org
  5. +1
    -0
      dropbox-sdk-python
  6. +3
    -0
      settings.json

+ 3
- 0
.gitignore View File

@ -102,3 +102,6 @@ venv.bak/
# mypy
.mypy_cache/
# Macoy's ignore
LOCAL_*

+ 3
- 0
.gitmodules View File

@ -1,3 +1,6 @@
[submodule "e-Paper"]
path = e-Paper
url = https://github.com/waveshare/e-Paper
[submodule "dropbox-sdk-python"]
path = dropbox-sdk-python
url = git://github.com/dropbox/dropbox-sdk-python.git

+ 46
- 0
HomeLifeDisplay.py View File

@ -0,0 +1,46 @@
#!/usr/bin/python3
import json
import os
settings = None
# debugEnableAPIRequests = True
debugEnableAPIRequests = False
def loadSettings():
global settings
settingsFilename = "settings.json"
# Load git ignored settings, if it exists (so I don't check in my API tokens)
if os.path.isfile("LOCAL_settings.json"):
settingsFilename = "LOCAL_settings.json"
print("Loading settings from {}".format(settingsFilename))
settingsFile = open(settingsFilename, "r")
settingsLines = settingsFile.readlines()
settingsFile.close()
settings = json.loads("".join(settingsLines))
print(settings)
loadSettings()
# Don't load something which can't be used
if settings["dropbox_token"] and debugEnableAPIRequests:
import dropbox
def main():
if not debugEnableAPIRequests:
print("Debug mode: no API requests will occur")
if settings["dropbox_token"] and debugEnableAPIRequests:
dbx = dropbox.Dropbox(settings["dropbox_token"])
print(dbx.users_get_current_account())
else:
print("No dropbox_token. Dropbox is disabled")
if __name__ == '__main__':
print("Started Home Life Display")
main()

+ 11
- 0
ReadMe.org View File

@ -41,6 +41,17 @@ git submodule init
git submodule update
#+END_SRC
*** Third Party APIs
**** Dropbox
Dropbox is included as a submodule.
[[https://github.com/dropbox/dropbox-sdk-python][Dropbox Python SDK]]
#+BEGIN_SRC sh
cd dropbox-sdk-python
sudo python3 setup.py install
#+END_SRC
*** E-paper Setup
**** Python dependencies


+ 1
- 0
dropbox-sdk-python

@ -0,0 +1 @@
Subproject commit 08cf819f367b6420ada29d91fad003dde12b1b5a

+ 3
- 0
settings.json View File

@ -0,0 +1,3 @@
{
"dropbox_token": ""
}

Loading…
Cancel
Save