WEEE-Open / pytarallo

Python T.A.R.A.L.L.O. API
MIT License
2 stars 4 forks source link

Implement Tarallo.move method #24

Closed steemnd closed 5 years ago

lvps commented 5 years ago

Here's a quick and dirty Python script we made a few days ago to bulk move some items (place numbers in a text file, automatically prepend prefix, move them all to the same place), it may be useful for some stuff:

#!/usr/bin/env python3

import requests
import getpass

rambox = '"RamBox"'

pw = getpass.getpass()

t = requests.Session()
result = t.post("https://127.0.0.1:8080/v1/session", headers={"Content-Type": "application/json"}, json={"username": "asd", "password": pw})
print(f"Login: {str(result.status_code)}")

with open("ram.txt") as f:
    for line in f:
        code = 'R' + line.strip()
        result = t.put(f"https://tarallo.weeeopen.it/v1/items/{code}/parent", headers={"Content-Type": "application/json"}, data=rambox)
        print(f"Moving {code}: {str(result.status_code)}")