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

#!/usr/bin/python
# -*- coding:utf-8 -*-
#this script takes a file as an option and adds that file to the db and posts the file to scuttlebutt
import optparse
import traceback
import os, sys
import subprocess
from tinydb import TinyDB, Query
def main():
#get options and arguments
p = optparse.OptionParser()
p.add_option('--file', '-f', action='store', dest='file', help='this needs to be a file path')
options, arguments = p.parse_args()
if options.file:
pathToImage=options.file
else:
print("you need to provide a file path")
exit(1)
def addFile(pathToImage, pathToDB, SSBidentify):
#init db
db = TinyDB(pathToDB)
#add to db
db.insert({'path': pathToImage, 'date': 4, 'ssb': SSBidentify})
print("all done, added to db")
#print("heres the whole db")
#print(db.all())
#unless you say don't post to ssb, post to ssb
if SSBidentify != -1:
#SEND TO SSB! WOOOO
try:
result = subprocess.call('./ssbpost.sh ' + pathToImage, shell=True)
except:
print 'traceback.format_exc():\n%s' % traceback.format_exc()
exit()
return pathToImage
if __name__ == '__main__':
main()