Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@octoprint.plugin.BlueprintPlugin.route("/deleteSnapshotImage/", methods=["DELETE"])
def delete_snapshot(self, snapshotFilename):
self._cameraManager.deleteSnapshot(snapshotFilename)
# input_name = "file"
# input_upload_path = input_name + "." + self._settings.global_get(["server", "uploads", "pathSuffix"])
#
# if input_upload_path in flask.request.values:
# # file to restore was uploaded
# sourceLocation = flask.request.values[input_upload_path]
# targetLocation = self._cameraManager.buildSnapshotFilenameLocation(snapshotFilename)
# os.rename(sourceLocation, targetLocation)
# pass
return flask.jsonify({
"snapshotFilename": snapshotFilename
@octoprint.plugin.BlueprintPlugin.route("/inputs/", methods=["GET"])
def get_input_status(self, identifier):
for rpi_input in self.rpi_inputs:
if identifier == self.to_int(rpi_input['index_id']):
return Response(json.dumps(rpi_input), mimetype='application/json')
return make_response('', 404)
@octoprint.plugin.BlueprintPlugin.route("/updateRepos/", methods=["PATCH"])
@octoprint.server.util.flask.restricted_access
@octoprint.server.admin_permission.require(403)
def updateRepos(self):
repo = flask.request.json['repo']
repoUrl = repo['repoUrl']
repoNamePath = self.getRepoNamePath(repoUrl)
self._sendStatus(line= 'Pull changes from remote:' + repoUrl, stream='stdout')
self.execute(['git', 'fetch'], cwd= repoNamePath)
self._sendStatus(line= 'Updating define library', stream='stdout')
gitInfo = self.getGitInfo(repoNamePath)
import json
import os
from datetime import datetime
from octoprint_PrintJobHistory import PrintJobModel, CameraManager
from octoprint_PrintJobHistory.api import Transform2CSV, TransformPrintJob2JSON
from octoprint_PrintJobHistory.common import StringUtils
from octoprint_PrintJobHistory.common.SettingsKeys import SettingsKeys
from octoprint_PrintJobHistory.CameraManager import CameraManager
class PrintJobHistoryAPI(octoprint.plugin.BlueprintPlugin):
# Converts the Model to JSON
# def _convertPrintJobHistoryModelsToDict(self, allJobsModels):
# result = []
# for job in allJobsModels:
# # jobAsDict = job.__dict__
# jobAsDict = job.__data__
#
# jobAsDict["printStartDateTimeFormatted"] = job.printStartDateTime.strftime('%d.%m.%Y %H:%M')
# jobAsDict["printEndDateTimeFormatted"] = job.printEndDateTime.strftime('%d.%m.%Y %H:%M')
# # # Calculate duration
# # duration = job.printEndDateTime - job.printStartDateTime
# duration = job.duration
# durationFormatted = StringUtils.secondsToText(duration)
# jobAsDict["durationFormatted"] = durationFormatted
#
@octoprint.plugin.BlueprintPlugin.route("/scriptset", methods=["POST"])
def setMaterialsData(self):
config = self._getConfigurationFile()
config["bed_clear_script"] = flask.request.values["bed_clear_script"];
self._writeConfigurationFile(config)
return flask.make_response("POST successful", 200)
def to_do_later(*args, **kwargs):
if to_do_later.__timer is not None:
to_do_later.__timer.cancel()
to_do_later.__timer = Timer(seconds, f, args, kwargs)
to_do_later.__timer.start()
to_do_later.__timer = None
return to_do_later
return new_decorator
class PrintTimeGeniusPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.StartupPlugin,
octoprint.plugin.ShutdownPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.BlueprintPlugin):
def __init__(self):
self._logger = logging.getLogger(__name__)
self._current_history = {}
dd = lambda: defaultdict(dd)
self._current_config = PrinterConfig() # dict of timing-relevant config commands
self._old_printer_config = self._current_config.as_list() # Cache of the config that is on disk.
##~~ SettingsPlugin mixin
def get_settings_defaults(self):
current_path = os.path.dirname(os.path.realpath(__file__))
built_in_analyzers = [
(gettext("All gcode analyzers (usually not as good as marlin-calc)"),
'"{{python}}" "{analyzer}" "{{{{gcode}}}}"'.format(
analyzer=os.path.join(current_path, "analyzers/analyze_gcode_comments.py")),
False),
(gettext("Marlin firmware simulation (replaces Octoprint built-in, faster and more accurate)"),
# coding=utf-8
from __future__ import absolute_import
import flask
import json
import os
import octoprint.plugin
import httplib2
import octoprint.server.util.flask
from octoprint.server import admin_permission
from octoprint.events import Events
from subprocess import call, Popen, PIPE
import threading
import time
import re
class BigBoxFirmwarePlugin(octoprint.plugin.BlueprintPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.SettingsPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.StartupPlugin):
def __init__(self):
self.templates = ('Configuration.h', 'Configuration_adv.h', 'pins_RUMBA.h')
self.depList = ['avr-libc', 'avrdude', 'make']
self.depInstalled = False
def on_startup(self, host, port):
self.depInstalled = self.check_dep()
self.getDefLib()
def on_after_startup(self):
return None, None, make_response("Mandatory parameter %s missing for command %s" % (parameter, command), 400)
return command, data, None
def create_ws_token(public_key = None, api_key = None):
from itsdangerous import URLSafeTimedSerializer
s = URLSafeTimedSerializer(api_key)
return s.dumps({ 'public_key': public_key })
class AstroprintPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.StartupPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.BlueprintPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.printer.PrinterCallback):
##~~ SettingsPlugin mixin
def initialize(self):
self.user = {}
self.designs = None
self.db = None
self.astroprintCloud = None
self.cameraManager = None
self.materialCounter= None
self._printerListener = None
def logOutHandler(sender, **kwargs):
self.onLogout()
import glob
import ctypes
import _ctypes
import platform
import subprocess
import psutil
import socket
import threading
import yaml
import logging
import logging.handlers
class SlicerPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.BlueprintPlugin):
##~~ SettingsPlugin mixin
def get_settings_defaults(self):
return dict(
# put your plugin's default settings here
)
##~~ AssetPlugin mixin
def get_assets(self):
# Define your plugin's asset files to automatically include in the
# core UI here.
return dict(
js=["js/profile_overrides.js", "js/slicer.js", "js/three.min.js", "js/STLLoader.js", "js/OrbitControls.js", "js/TransformControls.js", "js/Detector.js", "js/OrbitControls.js", "js/TransformControls.js", "js/STLBinaryExporter.js", "js/STLViewPort.js", "js/RectanglePacker.js", "js/ArrangeModels.js", "js/CheckerboardMaterial.js", "js/stats.min.js"],
css=["css/slicer.css"],