Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import sys
- import requests
- import argparse
- import urllib.request
- from urllib.parse import urlparse
- import os.path
- import json
- from pathlib import Path
- parser = argparse.ArgumentParser(description='Instaprinter callback')
- parser.add_argument('--path', help='file full path')
- parser.add_argument('--key', help='Api key')
- parser.add_argument('--printer', help='Printer key')
- args = parser.parse_args()
- apiKey = args.key
- printer = args.printer
- fullpath = args.path
- filename = os.path.basename(fullpath)
- domain = "https://instaprinter.techlab.paris"
- apiVersion = "v01"
- url = domain + "/api/" + apiVersion + "/" + printer + "/media/print"
- querystring = {"filename":filename}
- headers = {
- 'apikey': apiKey,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- response =json.loads(data.decode(encoding))
- if 'success' in response:
- print("success file print and remove")
- else:
- print("callback error : " + response['error'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement