Added python starter script
This commit is contained in:
Родитель
8bfc874e4d
Коммит
cfd0a38f9b
|
@ -0,0 +1,160 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
|
@ -0,0 +1,57 @@
|
|||
# Running this script will pull the latest commit from the main branch
|
||||
# of the specified stream and duplicate it inside a different branch.
|
||||
# (branch should exist already or the script will fail
|
||||
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.api.credentials import get_default_account, get_local_accounts
|
||||
from specklepy.transports.server import ServerTransport
|
||||
from specklepy.api import operations
|
||||
|
||||
# The id of the stream to work with (we're assuming it already exists in your default account's server)
|
||||
streamId = "YOUR_STREAM_ID_HERE"
|
||||
branchName = "YOUR_BRANCH_NAME_HERE"
|
||||
|
||||
|
||||
# Initialise the Speckle client pointing to your specific server.
|
||||
client = SpeckleClient(host="https://speckle.xyz")
|
||||
|
||||
# Get the default account
|
||||
account = get_default_account()
|
||||
# If you have more than one account, or the account is not the default, use get_local_accounts
|
||||
# accounts = get_local_accounts()
|
||||
# account = accounts[0]
|
||||
|
||||
# Authenticate using the account token
|
||||
client.authenticate(token=account.token)
|
||||
# Get the main branch with it's latest commit reference
|
||||
branch = client.branch.get(streamId, "main", 1)
|
||||
# Get the id of the object referenced in the commit
|
||||
objHash = branch.commits.items[0].referencedObject
|
||||
|
||||
|
||||
# Create the server transport for the specified stream.
|
||||
transport = ServerTransport(client=client, stream_id=streamId)
|
||||
|
||||
# Receive the object
|
||||
received_base = operations.receive(obj_id=objHash, remote_transport=transport)
|
||||
|
||||
|
||||
# The received object, process it as you wish.
|
||||
print("Received object:", received_base)
|
||||
|
||||
# TODO: Perform some operation on the received data
|
||||
|
||||
|
||||
# Send the points using a specific transport
|
||||
newHash = operations.send(base=received_base, transports=[transport])
|
||||
|
||||
# you can now create a commit on your stream with this object
|
||||
commit_id = client.commit.create(
|
||||
stream_id=streamId,
|
||||
branch_name=branchName,
|
||||
object_id=hash,
|
||||
message="Automatic commit created by AEC Tech Demo by AECTechDemo.py script",
|
||||
source_application="AEC Tech Python Script"
|
||||
)
|
||||
|
||||
print("Successfully created commit with id: ", commit_id)
|
Загрузка…
Ссылка в новой задаче