the public repo for the e-paper bulletin board. It's a bulletin board that syncs over scuttlebutt :)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

5 months ago
5 months ago
  1. #!/usr/bin/python
  2. # -*- coding:utf-8 -*-
  3. #this script takes a file as an option and adds that file to the db and posts the file to scuttlebutt
  4. import optparse
  5. import traceback
  6. import os, sys
  7. import subprocess
  8. from tinydb import TinyDB, Query
  9. def main():
  10. #get options and arguments
  11. p = optparse.OptionParser()
  12. p.add_option('--file', '-f', action='store', dest='file', help='this needs to be a file path')
  13. options, arguments = p.parse_args()
  14. if options.file:
  15. pathToImage=options.file
  16. else:
  17. print("you need to provide a file path")
  18. exit(1)
  19. def addFile(pathToImage, pathToDB, SSBidentify):
  20. #init db
  21. db = TinyDB(pathToDB)
  22. #add to db
  23. db.insert({'path': pathToImage, 'date': 4, 'ssb': SSBidentify})
  24. print("all done, added to db")
  25. #print("heres the whole db")
  26. #print(db.all())
  27. #unless you say don't post to ssb, post to ssb
  28. if SSBidentify != -1:
  29. #SEND TO SSB! WOOOO
  30. try:
  31. result = subprocess.call('./ssbpost.sh ' + pathToImage, shell=True)
  32. except:
  33. print 'traceback.format_exc():\n%s' % traceback.format_exc()
  34. exit()
  35. return pathToImage
  36. if __name__ == '__main__':
  37. main()