#!/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()