Package: threedeploy
Python app to automatically deploy a project to Thingiverse. Can be used manually, but is really supposed to be used via GitLab CI/CD or Github Actions for example.Providing the correct project structure, Thingideploy will do the following:Read Thing metadata fromthingdata.jsonCreate a Thing based on your provided data, or patch an existing oneUpdate the name, tags,description(currently broken on Thingi side apparently), license, category and WIP state of your thingPublish your thing, if flag is setUpload found 3D files / known project source files, or replace existing ones if local files have been modified since uploadUpload found images or replace existing onesAdditionaly, there is aproject creation modeto create theexpected folder structureand generate initial Thing metadata, as well as anAPI token request modeto generate your own API token.Please see myexample Repowhere Thingideploy is used for automatic CI/CD deployment!If you like my work please consider supporting my caffeine addiction!:construction: :construction: :construction:WIP WARNINGThis is a WIP. While all functions except updating Thing summary work, there is little in the way of error handling or sanity checking of data.:construction: :construction: :construction:Table of contentsUsageRequirementsProject creation modeThingiverse API token request modeDeployment mode - ThingiversePipeline usageExpected folder structurethingdata.jsonSupported filesModel files:Source files:Image files:UsageRequirementsWith Python 3 and PIP installed run:pip install --upgrade threedeployProject creation modethreedeploy--create-project--path=</path/to/new/project_folder>Will create theexpected project structurealong with all required files at the given location, insideproject_folder.Warning,project_folderitself needs to exist before calling, as the other modes could break if it doesn't already.Every text file that already exists, will be backed up likethingdata.json-->thingdata.json.backup_<Timestamp>before the new file is generated fresh. These backup files are put in the.gitignoreso make sure to notgit cleanthem away when overwriting your files accidentaly.Thingiverse API token request modethreedeploy--request-token-thingiverseWill open up your default webbrowser, promting you to login to Thingiverse and grant access to Thingideploy.After you have granted access, you will be forwarded to the Thingiverse homepage, but the response URL in your browsers address bar will contain your newly created API token. Copy this whole link and paste it into the command line when promted. Thingideploy will sanity check the link provided, and show you your API key for safekeeping.The API key is NOT saved in the application in any form and is only shown shown now! Save the key in a safe location, and use it later in deployment mode with the argument--deploy-project <YourApiToken.Warning, Thingideploy is currently in Thingiverses submission queue. Until it is approved by Thingiverse, only 10 people can use my applications client ID to use Thingideploy! Should that happen before Thingiverse approved Thingideploy, I will add instructions on how to create your own Thingiverse application to generate your own client ID so you can request an API token.Deployment mode - Thingiversethreedeploy--deploy-project-thingiverse=<YourApiToken>--path=</path/to/new/project_folder>Will deploy your project to Thingiverse. The first time this is called, a new Thing is created on Thingiverse,thingdata.jsonwill be updated with the newthing_id, and all your files will be uploaded for the first time. If the Thing already exists (checked withthingdata.json.thing_id) it will try to patch your Thing.Warning, If you run Thingideploy in a CI/CD pipeline, it will not be able to easily update your reposthingdata.json. It IS possible to give CI/CD runners push access, but since it will only need it once for initial deployment it is not really worth it. You will manually need to updatethingdata.jsonwith the new ThingID that is output to the command line and artifacted asThingId.txton successful creation!Please also checkPipeline usagefor information on how to automate deployment.Deploying your thing will:Compare model / gcode and source files on Thingiverse with your local ones, deleting and reuploading the ones where your local timestamp is newer than the upload timestamp on ThingiverseDelete and reupload all pictures, as there is no image timestamp to compare toSet display order of your images base on thefilenameReplace Thing summary with your README.md contents/CURRENTLY BROKEN IN APIReplace all tags on Thingiverse withthingdata.json.tagsIfthingdata.json.is_publishedis set, but thing is not already public, publish the ThingAddWork in progressinformation, depending onthingdata.json.is_wipSetLicenseandCategorydepending onthingdata.jsonWarning,  Thingiverse is amazingly slow to react to new file uploads and metadata changes. After calling with--deploy-project, allow Thingiverse to catch up for around 15 minutes before checking your Thing.Pipeline usageFor clarity, please see myexample Repowhere Threedeploy is used for automatic CI/CD deployment!Warning, If you run Threedeploy in a CI/CD pipeline, it will not be able to easily update your reposthingdata.json. It IS possible to give CI/CD runners push access, but since it will only need it once for initial deployment at Thingiverse for example it is not really worth it. You will manually need to updatethingdata.jsonwith the new ThingID that is output to the command line and artifacted asThingId.txton successful creation!Below is an example.gitlab-ci.ymlto automatically deploy and update things that are tracked in a git repo. You will need to put yourThingiverse API keyas a GitLab secret calledTHINGIVERSE_API_KEYto grant the runner access to Thingiverse.stages:
  - deploy

deploy_thingiverse:
  stage: deploy
  image: "python:3.9.6-buster"
  script:
    - pip install threedeploy
    - threedeploy --deploy-project-thingiverse="$THINGIVERSE_API_KEY" --path="$CI_PROJECT_DIR"/ProjectPath/
  artifacts:
    paths:
      - $CI_PROJECT_DIR/ProjectPath/CreationResponse.json
      - $CI_PROJECT_DIR/ProjectPath/PatchResponse.json
      - $CI_PROJECT_DIR/ProjectPath/ThingURL.txt
      - $CI_PROJECT_DIR/ProjectPath/ThingID.txt
    expire_in: 1 week
  only:
    changes:
      - ProjectPath/**/*
      - ProjectPath/*The runner will just install and run Threedeploy like you would on your local machine. Thingiverse responses are artifacted and the ThingURL and ThingID output just in case. Additionally, the job only triggers on changes in your 3d project path.Expected folder structureThe program expects files in the following structure:/project_folder/- Path that is input as command line argument like./thingideploy.py /home/user/project_foldergcode/- Location for sliced gcode filesREADME.md- Describing your gcode locationimg/- Location for imagesREADME.md- Describing your image location, see alsoimage filessource/- Location for project source file, FreeCAD, OpenSCAD project file etc.README.md- Describing your source file location3d/- Location for printable 3d files like stl, obj etc.README.md- Describing your 3d model file locationthingdata.json- Storage for Thing metadata / settingsREADME.md- Project description that is uploaded to Thingiverse asSummaryonce the API actually works again.gitignore- .gitignore containing ignored files created from this scriptAdditionally, the script will sometimes create the following files:project_folder/**/*.backup_<Timestamp>- When a new textfile is being created which already exists, the old one will be backed up hereCreationResponse.json- Dump of the API response during first project deploymentPatchResponse.json- Dump of the API response during project patchingInitialCreation- Will get touched after initial creation, only to notify CI/CD pipelines to updatethingdata.jsonwith the newly receivedthing_idthingdata.jsonExamplethingdata.json, providing Thing metadata:{"name":"Threedeploy - Debug","tags":["NewTag","SecondTag"],"thingiverse_id":4932869,"thingiverse_creator":"Chrismettal","thingiverse_is_wip":true,"thingiverse_license":"cc","thingiverse_category":"3D Printer Parts","thingiverse_is_published":true}This file is required to exist before deployment, and is best generated with the--create-projectoption.thingiverse_creatoris just used as a plausibility check before trying to patch a Thing that you don't own, so it needs to contain your Thingiverse name.All other options have direct impact on all Thing settings that are exposed to the API. Thing summary is supposed to be set via the projectsproject_path/README.mdbut currently does not work.Supported filesSupported file extensions are practically arbitrary for Thingideploy and might later be read in from a seperate file rather than being hardcoded. Only there as a sanity check so you don't try uploading executables to Thingiverse.Model files:.stl.stp.STEP.obj.3mf.gcodeSource files:.FCStd.scad.f3dImage files:.png.jpg.bmpImage files are sorted (ranked) via the file name. Make sure to use the following naming format:RR-YourImageName.*WhereRRis a 2 char integer for image ranking, for example01-Cover.pngwill put your that file as the first image in order. Make sure every image has a unique rank name, like:01-Cover.png02-Side.png...12-FinalPicture.png