API Sample Code - Bulk Uploader

Discussion in 'Shapeways API' started by stonysmith, Apr 18, 2015.

  1. stonysmith
    stonysmith Well-Known Member Moderator
    The question often comes up "How can I upload many models at once?" For a good while now, I've been using the API for various shop maintenance tasks, and I thought I'd share a bulk uploader that I whipped up.

    Read the directions in the file. <grin> Check back from time to time.. if someone has suggestions, I'll update the tools.

    The tools here require the Python programming language which is available for free from python.org.

    Disclaimer: This set of tools is not for you unless you have at least minimal programming experience/skills, and/or the of desire to "do it yourself". If you want a completely pre-packaged "one button" solution, hire a programmer.

    This code is shared here in the hopes that I can ease some of your frustrations. No warranty is implied.
    If you'd like to say ThankYou, I'd be happy to accept donations thru PayPal. <grin>
     

    Attached Files:

  2. hans_lambermont
    hans_lambermont Shapeways Employee Dev Team
    FYI the GetKeys.py script has a bug where it saves the consumer key secret at the place of the access token secret.

    -- Hans

    ps. I propose to rewrite to use the Shapeways python API at https://github.com/Shapeways/python-shapeways
     
  3. Bapsite
    Bapsite Member
    Hey,

    First of all I would like to say thank you for this code. I use Blender, and is has Python built in.
    I plannend on using your code to make an addon to upload files directly in Blender.

    I've been thinkering with your code for while now and I can not get it to work. I used Python 2.7, so it should work, but i get authentication errors.

    The GetListofModels gives me an error, saying there is an "oauth_problem=signature_invalid".
    When I try the uploader, it reads the file that needs to be uploaded. But then it fails.
    I've wiresharked it and saw that i get a 401 from the api.

    So i am guessing it is a authentication issue, but i can not figure it out ...
     
  4. stonysmith
    stonysmith Well-Known Member Moderator
    Yeah.. that was where I started.. trying to get some tools built for Blender. Unfortunately, Blender uses Python 3.x and I have been unable to find an Oauth1 library that works with Python 3.

    You'll have to install Python 2.7.. The good news is that I have automated jobs that run every day that work just fine in 2.7

    The even better news.. I think that Shapeways is considering retiring Oauth1 and will go with an authentication protocol that is more common.,
     
    Last edited: Mar 13, 2017
  5. Bapsite
    Bapsite Member
    Yeah, I have already given up on that path on making it to work in Blender :).

    I have the 2.7 installed but when i try your scripts it just does not work. I can get to update the keys, that works fine. But the uploader script just failes :(
     
  6. stonysmith
    stonysmith Well-Known Member Moderator
    Did you change this line of text in uploader.py? It needs to point the the folder where your files are stored.
    Code:
    path="c:/users/path/to/files"
    Also, there should be a file written "results.txt" which should contain some messages.
     
  7. stonysmith
    stonysmith Well-Known Member Moderator
  8. Bapsite
    Bapsite Member
    Hey,

    Yes, i changed to the correct location where my stl's reside. The script, selects ons, and within seconds it outputs xxx/xxxx/xxx.stl failed. results.txt does not get written also.

    This is your line, and after this line, the script fails : print filename+","+result
     
  9. Bapsite
    Bapsite Member
  10. imdaveho
    imdaveho Shapeways Employee Product Team
    @Bapsite bulk editing is a large focus of mine wrt the API. To clarify, we currently support OAuth1.0a (not 2.0 as @stonysmith suggested) we are currently beta testing OAuth2.0 which should greatly improve the authorization ergonomics for tools like Blender.

    I'm also interested in a plugin for Blender that helps our community upload directly and make bulk edits. Let's get in touch soon to see what things you struggled with/ would like to see from Shapeways.
     
  11. stonysmith
    stonysmith Well-Known Member Moderator
    My bad.. edited...