main
alex 2024-05-09 22:40:37 +02:00
commit bb2f8dbea1
815 changed files with 159192 additions and 0 deletions

3
builder/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM octoprint/octoprint
COPY octoprint /octoprint

View File

@ -0,0 +1,16 @@
version: '2.4'
services:
octoprint_server_test2:
container_name: octoprint-server-test2
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 127.0.0.1:50138:80
volumes:
- octoprint-server-test2:/octoprint
volumes:
octoprint-server-test2:

View File

@ -0,0 +1,74 @@
accessControl:
userfile: /octoprint/octoprint/users.yaml
api:
key: 91EEB0475E5844059C3CBC0C18E37B63
appearance:
color: white
name: My Template
plugins:
announcements:
_config_version: 1
channels:
_blog:
read_until: 1711358100
_important:
read_until: 1698310200
_octopi:
read_until: 1684929600
_plugins:
read_until: 1714176000
_releases:
read_until: 1713957300
bambu_printer:
access_code: '1234'
device_type: P1P
host: 127.0.0.1
serial: '1234'
classicwebcam:
_config_version: 1
snapshot: http://localhost:8080/?action=snapshot
stream: /webcam/?action=stream
discovery:
upnpUuid: f208a345-7fab-4b7b-8922-a12766395145
errortracking:
unique_id: 2074483d-5218-452c-992f-07225b0f7efd
gcodeviewer:
_config_version: 1
softwareupdate:
_config_version: 9
tracking:
enabled: false
unique_id: 2aa3b43d-6962-431d-a80b-818b7230d03e
virtual_printer:
_config_version: 1
printerProfiles:
default: _default
serial:
autoconnect: true
server:
commands:
serverRestartCommand: s6-svc -r /var/run/s6/services/octoprint
firstRun: false
onlineCheck:
enabled: false
pluginBlacklist:
enabled: true
secretKey: xZHLyQYSTO24lFaEE7yHGoMKiYcJWE46
seenWizards:
backup: null
classicwebcam: 1
corewizard: 4
file_check: 1
tracking: null
temperature:
profiles:
- bed: 100
chamber: null
extruder: 210
name: ABS
- bed: 60
chamber: null
extruder: 180
name: PLA
webcam:
ffmpeg: /usr/bin/ffmpeg

View File

@ -0,0 +1,74 @@
accessControl:
userfile: /octoprint/octoprint/users.yaml
api:
key: 91EEB0475E5844059C3CBC0C18E37B63
appearance:
color: white
name: My A2
plugins:
announcements:
_config_version: 1
channels:
_blog:
read_until: 1711358100
_important:
read_until: 1698310200
_octopi:
read_until: 1684929600
_plugins:
read_until: 1714176000
_releases:
read_until: 1713957300
bambu_printer:
access_code: '1234'
device_type: P1P
host: 127.0.0.1
serial: '1234'
classicwebcam:
_config_version: 1
snapshot: http://localhost:8080/?action=snapshot
stream: /webcam/?action=stream
discovery:
upnpUuid: f208a345-7fab-4b7b-8922-a12766395145
errortracking:
unique_id: 2074483d-5218-452c-992f-07225b0f7efd
gcodeviewer:
_config_version: 1
softwareupdate:
_config_version: 9
tracking:
enabled: false
unique_id: 2aa3b43d-6962-431d-a80b-818b7230d03e
virtual_printer:
_config_version: 1
printerProfiles:
default: _default
serial:
autoconnect: true
server:
commands:
serverRestartCommand: s6-svc -r /var/run/s6/services/octoprint
firstRun: false
onlineCheck:
enabled: false
pluginBlacklist:
enabled: true
secretKey: xZHLyQYSTO24lFaEE7yHGoMKiYcJWE46
seenWizards:
backup: null
classicwebcam: 1
corewizard: 4
file_check: 1
tracking: null
temperature:
profiles:
- bed: 100
chamber: null
extruder: 210
name: ABS
- bed: 60
chamber: null
extruder: 180
name: PLA
webcam:
ffmpeg: /usr/bin/ffmpeg

View File

@ -0,0 +1,22 @@
{
"last_version": "1.10.0",
"seen_versions": 1,
"server_starts": 8,
"prints_started": 0,
"prints_cancelled": 0,
"prints_errored": 0,
"prints_finished": 0,
"prints_started_per_weekday": {},
"print_duration_total": 0.0,
"print_duration_cancelled": 0.0,
"print_duration_errored": 0.0,
"print_duration_finished": 0.0,
"longest_print_duration": 0.0,
"longest_print_date": 0,
"files_uploaded": 0,
"files_deleted": 0,
"plugins_installed": 0,
"plugins_uninstalled": 0,
"most_plugins": 20,
"achievements": 1
}

View File

@ -0,0 +1,39 @@
{
"stats": {
"last_version": "1.10.0",
"seen_versions": 1,
"server_starts": 8,
"prints_started": 0,
"prints_cancelled": 0,
"prints_errored": 0,
"prints_finished": 0,
"prints_started_per_weekday": {},
"print_duration_total": 0.0,
"print_duration_cancelled": 0.0,
"print_duration_errored": 0.0,
"print_duration_finished": 0.0,
"longest_print_duration": 0.0,
"longest_print_date": 0,
"files_uploaded": 0,
"files_deleted": 0,
"plugins_installed": 0,
"plugins_uninstalled": 0,
"most_plugins": 20,
"created": 1715245186,
"created_version": "1.10.0"
},
"achievements": {
"the_wizard": 1715245188
},
"state": {
"date_last_print": "",
"prints_today": 0,
"date_last_cancelled_print": "",
"prints_cancelled_today": 0,
"consecutive_prints_cancelled_today": 0,
"file_last_print": "",
"consecutive_prints_of_same_file": 0,
"date_last_weekend_print": "",
"consecutive_weekend_prints": 0
}
}

View File

@ -0,0 +1 @@
{"version": 1, "timestamp": 1715248737}

View File

@ -0,0 +1,5 @@
- roomtemp
- - GcodeEditor
- '>=0.1.1,<=0.2.8'
- - gcodeleveling
- '>=0.1.0,<=0.1.1'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,6 @@
/:
- _count: 32
_timestamp: 1715285965.6765628
base_url: http://localhost:50136/
path: /
query_string: l10n=en

View File

@ -0,0 +1,73 @@
__version: 1.10.0
bambu_printer:
available: false
compatible: true
disabled: false
error: null
hash: c5c2a267896bf792143ac3aac05223f7
information:
local:
name: 0.0.18
value: 0.0.18
needs_online: true
remote:
name: 0.0.18
release_notes: https://github.com/jneilliii/OctoPrint-BambuPrinter/releases/tag/0.0.18
value: 0.0.18
online: true
possible: true
timestamp: 1715253505.066055
file_check:
available: false
compatible: true
disabled: false
error: null
hash: f595880f4ef52d3ad09769ae10d6157f
information:
local:
name: 2024.3.27
value: 2024.3.27
needs_online: true
remote:
name: 2024.3.27
release_notes: https://github.com/OctoPrint/OctoPrint-FileCheck/releases/tag/2024.3.27
value: 2024.3.27
online: true
possible: true
timestamp: 1715245191.0575087
firmware_check:
available: false
compatible: true
disabled: false
error: null
hash: 2cc0c5c664767763a036f68d2318d063
information:
local:
name: 2021.10.11
value: 2021.10.11
needs_online: true
remote:
name: 2021.10.11
release_notes: https://github.com/OctoPrint/OctoPrint-FirmwareCheck/releases/tag/2021.10.11
value: 2021.10.11
online: true
possible: true
timestamp: 1715245191.0564404
octoprint:
available: false
compatible: true
disabled: false
error: null
hash: b188a004c8f9dfd4213157c84536db06
information:
local:
name: 1.10.0
value: 1.10.0
needs_online: true
remote:
name: 1.10.0
release_notes: https://github.com/OctoPrint/OctoPrint/releases/tag/1.10.0
value: 1.10.0
online: true
possible: true
timestamp: 1715245191.0577404

View File

@ -0,0 +1,202 @@
// source: js/app/client/base.js
(function(global,factory){if(typeof define==="function"&&define.amd){define("OctoPrintClient",["jquery","lodash"],factory);}else{global.OctoPrintClient=factory(global.$,global._);global.OctoPrint=new global.OctoPrintClient();}})(this,function($,_){var PluginRegistry=function(base){this.base=base;this.components={};};var OctoPrintClient=function(options){this.options=options||{baseurl:undefined,apikey:undefined,locale:undefined};this.components={};this.plugins=new PluginRegistry(this);};OctoPrintClient.registerComponent=function(name,component){Object.defineProperty(OctoPrintClient.prototype,name,{get:function(){if(this.components[name]!==undefined){return this.components[name];}
var instance=new component(this);this.components[name]=instance;return instance;},enumerable:false,configurable:false});};OctoPrintClient.registerPluginComponent=function(name,component){Object.defineProperty(PluginRegistry.prototype,name,{get:function(){if(this.components[name]!==undefined){return this.components[name];}
var instance=new component(this.base);this.components[name]=instance;return instance;},enumerable:false,configurable:false});};var noCache=function(opts){opts=opts||{};var params=$.extend({},opts);params.headers=$.extend({},params.headers||{});params.headers["Cache-Control"]="no-cache";return params;};var contentTypeJson=function(opts){opts=opts||{};var params=$.extend({},opts);params.contentType="application/json; charset=UTF-8";return params;};var contentTypeFalse=function(opts){opts=opts||{};var params=$.extend({},opts);params.contentType=false;return params;};var noProcessData=function(opts){opts=opts||{};var params=$.extend({},opts);params.processData=false;return params;};var replaceUndefinedWithNull=function(key,value){if(value===undefined){return null;}else{return value;}};OctoPrintClient.prototype.getBaseUrl=function(){var url=this.options.baseurl;if(!_.endsWith(url,"/")){url=url+"/";}
return url;};OctoPrintClient.prototype.getParsedBaseUrl=function(location){if(!this.options.baseurl)return"";try{var url=new URL(this.options.baseurl);}catch(e){location=location||window.location;var parsed=new URL(location);var path=this.options.baseurl;if(!path||path[0]!=="/"){path="/"+(path?path:"");}
var url=new URL(parsed.protocol+"//"+parsed.host+path);}
return url;};OctoPrintClient.prototype.getCookieSuffix=function(){if(!this.options.baseurl)return"";var url=this.getParsedBaseUrl();var port=url.port||(url.protocol==="https:"?443:80);if(url.pathname&&url.pathname!=="/"){var path=url.pathname;if(path.endsWith("/")){path=path.substring(0,path.length-1);}
return"_P"+port+"_R"+path.replace(/\//g,"|");}else{return"_P"+port;}};OctoPrintClient.prototype.getCookieName=function(name){return name+this.getCookieSuffix();};OctoPrintClient.prototype.getCookie=function(name){name=this.getCookieName(name);return("; "+document.cookie).split("; "+name+"=").pop().split(";")[0];};OctoPrintClient.prototype.getRequestHeaders=function(method,additional,opts){if(arguments.length<=1){if(!_.isString(method)){additional=method;console.warn("Calling OctoPrintClient.getRequestHeaders with additional "+"headers as the first parameter is deprecated. Please "+"consult the docs about the current signature and adjust "+"your code accordingly.");}}
method=method||"GET";additional=additional||{};opts=opts||{};var headers=$.extend({},additional);if(this.options.apikey){headers["X-Api-Key"]=this.options.apikey;}else{var csrfToken=this.getCookie("csrf_token");if(!/^(GET|HEAD|OPTIONS)$/.test(method)&&csrfToken&&!opts.crossDomain){headers["X-CSRF-Token"]=csrfToken;}}
if(this.options.locale!==undefined){headers["X-Locale"]=this.options.locale;}
return headers;};OctoPrintClient.prototype.ajax=function(method,url,opts){opts=opts||{};method=opts.method||method||"GET";url=opts.url||url||"";var urlToCall=url;if(!_.startsWith(url,"http://")&&!_.startsWith(url,"https://")){urlToCall=this.getBaseUrl()+url;opts.url=urlToCall;}
var headers=this.getRequestHeaders(method,opts.headers,opts);var params=$.extend({},opts);params.type=method;params.headers=headers;params.dataType=params.dataType||"json";return $.ajax(urlToCall,params);};OctoPrintClient.prototype.ajaxWithData=function(method,url,data,opts){opts=opts||{};var params=$.extend({},opts);params.data=data;return this.ajax(method,url,params);};OctoPrintClient.prototype.get=function(url,opts){return this.ajax("GET",url,opts);};OctoPrintClient.prototype.getWithQuery=function(url,data,opts){return this.ajaxWithData("GET",url,data,opts);};OctoPrintClient.prototype.post=function(url,data,opts){return this.ajaxWithData("POST",url,data,noCache(opts));};OctoPrintClient.prototype.postForm=function(url,data,opts){var form=new FormData();_.each(data,function(value,key){form.append(key,value);});return this.post(url,form,contentTypeFalse(noProcessData(opts)));};OctoPrintClient.prototype.postJson=function(url,data,opts){return this.post(url,JSON.stringify(data,replaceUndefinedWithNull),contentTypeJson(opts));};OctoPrintClient.prototype.put=function(url,data,opts){return this.ajaxWithData("PUT",url,data,noCache(opts));};OctoPrintClient.prototype.putJson=function(url,data,opts){return this.put(url,JSON.stringify(data,replaceUndefinedWithNull),contentTypeJson(opts));};OctoPrintClient.prototype.patch=function(url,data,opts){return this.ajaxWithData("PATCH",url,data,noCache(opts));};OctoPrintClient.prototype.patchJson=function(url,data,opts){return this.patch(url,JSON.stringify(data,replaceUndefinedWithNull),contentTypeJson(opts));};OctoPrintClient.prototype.delete=function(url,opts){return this.ajax("DELETE",url,opts);};OctoPrintClient.prototype.download=function(url,opts){var params=$.extend({},opts||{});params.dataType="text";return this.get(url,params);};OctoPrintClient.prototype.bulkDownloadUrl=function(url,files){return(url+"?"+
_.map(files,function(f){return"files="+encodeURIComponent(f);}).join("&"));};OctoPrintClient.prototype.upload=function(url,file,filename,additional){additional=additional||{};var fileData;if(file instanceof jQuery){fileData=file[0].files[0];}else if(typeof file=="string"){fileData=$(file)[0].files[0];}else{fileData=file;}
filename=filename||fileData.name;var filesize=fileData.size;var form=new FormData();form.append("file",fileData,filename);_.each(additional,function(value,key){form.append(key,value);});var deferred=$.Deferred();var request=new XMLHttpRequest();request.onreadystatechange=function(){if(request.readyState==4){deferred.notify({loaded:filesize,total:filesize});var success=(request.status>=200&&request.status<300)||request.status===304;var error,json,statusText;try{json=JSON.parse(request.response);statusText="success";}catch(e){success=false;error=e;statusText="parsererror";}
if(success){deferred.resolve([json,statusText,request]);}else{if(!statusText){statusText=request.statusText;}
deferred.reject([request,statusText,error]);}}};request.ontimeout=function(){deferred.reject([request,"timeout","Timeout"]);};request.upload.addEventListener("loadstart",function(e){deferred.notify({loaded:e.loaded,total:e.total});});request.upload.addEventListener("progress",function(e){deferred.notify({loaded:e.loaded,total:e.total});});request.upload.addEventListener("loadend",function(e){deferred.notify({loaded:e.loaded,total:e.total});});var method="POST";var headers=this.getRequestHeaders(method);var urlToCall=url;if(!_.startsWith(url,"http://")&&!_.startsWith(url,"https://")){urlToCall=this.getBaseUrl()+url;}
request.open(method,urlToCall);_.each(headers,function(value,key){request.setRequestHeader(key,value);});request.send(form);return deferred.promise();};OctoPrintClient.prototype.issueCommand=function(url,command,payload,opts){payload=payload||{};var data=$.extend({},payload);data.command=command;return this.postJson(url,data,opts);};OctoPrintClient.prototype.getSimpleApiUrl=function(plugin){return"api/plugin/"+plugin;};OctoPrintClient.prototype.simpleApiGet=function(plugin,opts){return this.get(OctoPrintClient.prototype.getSimpleApiUrl(plugin),opts);};OctoPrintClient.prototype.simpleApiCommand=function(plugin,command,payload,opts){return this.issueCommand(OctoPrintClient.prototype.getSimpleApiUrl(plugin),command,payload,opts);};OctoPrintClient.prototype.getBlueprintUrl=function(plugin){return"plugin/"+plugin+"/";};OctoPrintClient.createRejectedDeferred=function(){var deferred=$.Deferred();deferred.reject(arguments);return deferred;};OctoPrintClient.createCustomException=function(name){var constructor;if(_.isFunction(name)){constructor=name;}else{constructor=function(message){this.name=name;this.message=message;this.stack=new Error().stack;};}
constructor.prototype=Object.create(Error.prototype);constructor.prototype.constructor=constructor;return constructor;};OctoPrintClient.InvalidArgumentError=OctoPrintClient.createCustomException("InvalidArgumentError");OctoPrintClient.deprecated=function(deprecatedFct,newFct,fn){return function(){console.warn(deprecatedFct+" is deprecated, please use the new "+
newFct+" function instead");return fn.apply(this,arguments);};};OctoPrintClient.deprecatedMethod=function(object,oldNamespace,oldFct,newNamespace,newFct,fn){object[oldFct]=OctoPrintClient.deprecated(oldNamespace+"."+oldFct,newNamespace+"."+newFct,fn);};OctoPrintClient.deprecatedVariable=function(object,oldNamespace,oldVar,newNamespace,newVar,getter,setter){Object.defineProperty(object,oldVar,{get:function(){return OctoPrintClient.deprecated(oldNamespace+"."+oldVar,newNamespace+"."+newVar,getter)();},set:function(val){OctoPrintClient.deprecated(oldNamespace+"."+oldVar,newNamespace+"."+newVar,setter)(val);}});};OctoPrintClient.escapePath=function(path){return _.map(path.split("/"),function(p){return encodeURIComponent(p);}).join("/");};return OctoPrintClient;});
;
// source: js/app/client/socket.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery","lodash","sockjs"],factory);}else{factory(global.OctoPrintClient,global.$,global._,global.SockJS);}})(this,function(OctoPrintClient,$,_,SockJS){var normalClose=1000;var OctoPrintSocketClient=function(base){var self=this;this.base=base;this.options={timeouts:[0,1,1,2,3,5,8,13,20,40,100],connectTimeout:5000,transportTimeout:4000,rateSlidingWindowSize:20};this.socket=undefined;this.reconnecting=false;this.reconnectTrial=0;this.registeredHandlers={};this.rateThrottleFactor=1;this.rateBase=500;this.rateLastMeasurements=[];this.connectTimeout=undefined;this.onMessage("connected",function(){if(self.connectTimeout){clearTimeout(self.connectTimeout);self.connectTimeout=undefined;}});};OctoPrintSocketClient.prototype.propagateMessage=function(event,data){var start=new Date().getTime();var eventObj={event:event,data:data};var catchAllHandlers=this.registeredHandlers["*"];if(catchAllHandlers&&catchAllHandlers.length){_.each(catchAllHandlers,function(handler){handler(eventObj);});}
var handlers=this.registeredHandlers[event];if(handlers&&handlers.length){_.each(handlers,function(handler){handler(eventObj);});}
var end=new Date().getTime();this.analyzeTiming(end-start);};OctoPrintSocketClient.prototype.analyzeTiming=function(measurement){while(this.rateLastMeasurements.length>=this.options.rateSlidingWindowSize){this.rateLastMeasurements.shift();}
this.rateLastMeasurements.push(measurement);var processingLimit=this.rateThrottleFactor*this.rateBase;if(measurement>processingLimit){this.onRateTooHigh(measurement,processingLimit);}else if(this.rateThrottleFactor>1){var maxProcessingTime=Math.max.apply(null,this.rateLastMeasurements);var lowerProcessingLimit=(this.rateThrottleFactor-1)*this.rateBase;if(maxProcessingTime<lowerProcessingLimit){this.onRateTooLow(maxProcessingTime,lowerProcessingLimit);}}};OctoPrintSocketClient.prototype.increaseRate=function(){if(this.rateThrottleFactor<=1){this.rateThrottleFactor=1;return;}
this.rateThrottleFactor--;this.sendThrottleFactor();};OctoPrintSocketClient.prototype.decreaseRate=function(){this.rateThrottleFactor++;this.sendThrottleFactor();};OctoPrintSocketClient.prototype.sendThrottleFactor=function(){this.sendMessage("throttle",this.rateThrottleFactor);};OctoPrintSocketClient.prototype.sendAuth=function(userId,session){this.sendMessage("auth",userId+":"+session);};OctoPrintSocketClient.prototype.sendMessage=function(type,payload){var data={};data[type]=payload;this.socket.send(JSON.stringify(data));};OctoPrintSocketClient.prototype.connect=function(opts){opts=opts||{};var self=this;self.disconnect();var url=self.base.options.baseurl;if(!_.endsWith(url,"/")){url+="/";}
var timeout=self.options.connectTimeout;if(opts.hasOwnProperty("connectTimeout")){timeout=opts.connectTimeout;delete opts.connectTimeout;}
var onOpen=function(){self.reconnecting=false;self.reconnectTrial=0;self.onConnected();};var onClose=function(e){if(e.code===normalClose){return;}
if(self.onReconnectAttempt(self.reconnectTrial)){return;}
self.onDisconnected(e.code);if(self.reconnectTrial<self.options.timeouts.length){var timeout=self.options.timeouts[self.reconnectTrial];setTimeout(function(){self.reconnect();},timeout*1000);self.reconnectTrial++;}else{self.onReconnectFailed();}};var onMessage=function(msg){_.each(msg.data,function(data,key){self.propagateMessage(key,data);});};if(self.connectTimeout){clearTimeout(self.connectTimeout);}
if(timeout>0){self.connectTimeout=setTimeout(function(){self.onConnectTimeout();},timeout);}
var transportTimeout=self.options.transportTimeout;if(opts.hasOwnProperty("transportTimeout")){transportTimeout=opts.transportTimeout;delete opts.transportTimeout;}
opts.timeout=transportTimeout;self.socket=new SockJS(url+"sockjs",undefined,opts);self.socket.onopen=onOpen;self.socket.onclose=onClose;self.socket.onmessage=onMessage;};OctoPrintSocketClient.prototype.reconnect=function(){this.disconnect();this.socket=undefined;this.connect();};OctoPrintSocketClient.prototype.disconnect=function(){if(this.socket!==undefined){this.socket.close();}};OctoPrintSocketClient.prototype.onMessage=function(message,handler){if(!this.registeredHandlers.hasOwnProperty(message)){this.registeredHandlers[message]=[];}
this.registeredHandlers[message].push(handler);return this;};OctoPrintSocketClient.prototype.removeMessage=function(message,handler){if(!this.registeredHandlers.hasOwnProperty(message)){return;}
const index=OctoPrint.socket.registeredHandlers[message].indexOf(handler);if(index>-1){OctoPrint.socket.registeredHandlers[message].splice(index,1);}};OctoPrintSocketClient.prototype.onReconnectAttempt=function(trial){};OctoPrintSocketClient.prototype.onReconnectFailed=function(){};OctoPrintSocketClient.prototype.onConnected=function(){};OctoPrintSocketClient.prototype.onDisconnected=function(code){};OctoPrintSocketClient.prototype.onConnectTimeout=function(){};OctoPrintSocketClient.prototype.onRateTooLow=function(measured,minimum){this.increaseRate();};OctoPrintSocketClient.prototype.onRateTooHigh=function(measured,maximum){this.decreaseRate();};OctoPrintClient.registerComponent("socket",OctoPrintSocketClient);return OctoPrintSocketClient;});
;
// source: js/app/client/access.js
(function(global,factory){if(typeof define==="function"&&define.amd){define("OctoPrintAccessClient",["OctoPrintClient"],factory);}else{global.OctoPrintAccessClient=factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var baseAccessUrl="api/access";var OctoPrintAccessPermissionsClient=function(access){this.access=access;this.base=this.access.base;var baseUrl=baseAccessUrl+"/permissions";this.url=function(){if(arguments.length){return baseUrl+"/"+Array.prototype.join.call(arguments,"/");}else{return baseUrl;}};};OctoPrintAccessPermissionsClient.prototype.list=function(opts){return this.base.get(this.url(),opts);};var OctoPrintAccessGroupsClient=function(access){this.access=access;this.base=this.access.base;var baseUrl=baseAccessUrl+"/groups";this.url=function(){if(arguments.length){return baseUrl+"/"+Array.prototype.join.call(arguments,"/");}else{return baseUrl;}};};OctoPrintAccessGroupsClient.prototype.list=function(opts){return this.base.get(this.url(),opts);};OctoPrintAccessGroupsClient.prototype.add=function(group,opts){if(!group.key){throw new OctoPrintClient.InvalidArgumentError("group key must be set");}
if(!group.name){throw new OctoPrintClient.InvalidArgumentError("group name must be set");}
var data={key:group.key,name:group.name,description:group.description,permissions:group.permissions,subgroups:group.subgroups,default:group.default};return this.base.postJson(this.url(),data,opts);};OctoPrintAccessGroupsClient.prototype.get=function(key,opts){if(!key){throw new OctoPrintClient.InvalidArgumentError("group key must be set");}
return this.base.get(this.url(key),opts);};OctoPrintAccessGroupsClient.prototype.update=function(group,opts){if(!group.key){throw new OctoPrintClient.InvalidArgumentError("group key must be set");}
var data={description:group.hasOwnProperty("description")?group.description:"",permissions:group.permissions,subgroups:group.subgroups,default:group.default};return this.base.putJson(this.url(group.key),data,opts);};OctoPrintAccessGroupsClient.prototype.delete=function(key,opts){if(!key){throw new OctoPrintClient.InvalidArgumentError("group key must be set");}
return this.base.delete(this.url(key),opts);};var OctoPrintAccessUsersClient=function(access){this.access=access;this.base=this.access.base;var baseUrl=baseAccessUrl+"/users";this.url=function(){if(arguments.length){return baseUrl+"/"+Array.prototype.join.call(arguments,"/");}else{return baseUrl;}};};OctoPrintAccessUsersClient.prototype.list=function(opts){return this.base.get(this.url(),opts);};OctoPrintAccessUsersClient.prototype.add=function(user,opts){if(!user.name||!user.password){throw new OctoPrintClient.InvalidArgumentError("Both user's name and password need to be set");}
var data={name:user.name,password:user.password,groups:user.hasOwnProperty("groups")?user.groups:[],permissions:user.hasOwnProperty("permissions")?user.permissions:[],active:user.hasOwnProperty("active")?!!user.active:true,admin:user.hasOwnProperty("admin")?!!user.admin:false};return this.base.postJson(this.url(),data,opts);};OctoPrintAccessUsersClient.prototype.get=function(name,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
return this.base.get(this.url(name),opts);};OctoPrintAccessUsersClient.prototype.update=function(name,active,admin,permissions,groups,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
var data={active:!!active,groups:groups,permissions:permissions,admin:!!admin};return this.base.putJson(this.url(name),data,opts);};OctoPrintAccessUsersClient.prototype.delete=function(name,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
return this.base.delete(this.url(name),opts);};OctoPrintAccessUsersClient.prototype.changePassword=function(name,password,oldpw,opts){if(_.isObject(oldpw)){opts=oldpw;oldpw=undefined;}
if(!name||!password){throw new OctoPrintClient.InvalidArgumentError("user name and new password must be set");}
var data={password:password};if(oldpw){data["current"]=oldpw;}
return this.base.putJson(this.url(name,"password"),data,opts);};OctoPrintAccessUsersClient.prototype.generateApiKey=function(name,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
return this.base.postJson(this.url(name,"apikey"),opts);};OctoPrintAccessUsersClient.prototype.resetApiKey=function(name,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
return this.base.delete(this.url(name,"apikey"),opts);};OctoPrintAccessUsersClient.prototype.getSettings=function(name,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
return this.base.get(this.url(name,"settings"),opts);};OctoPrintAccessUsersClient.prototype.saveSettings=function(name,settings,opts){if(!name){throw new OctoPrintClient.InvalidArgumentError("user name must be set");}
settings=settings||{};return this.base.patchJson(this.url(name,"settings"),settings,opts);};var OctoPrintAccessClient=function(base){this.base=base;this.permissions=new OctoPrintAccessPermissionsClient(this);this.groups=new OctoPrintAccessGroupsClient(this);this.users=new OctoPrintAccessUsersClient(this);};OctoPrintClient.registerComponent("access",OctoPrintAccessClient);return OctoPrintAccessClient;});
;
// source: js/app/client/browser.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var loginUrl="api/login";var logoutUrl="api/logout";var OctoPrintBrowserClient=function(base){this.base=base;};OctoPrintBrowserClient.prototype.login=function(username,password,remember,opts){var data={user:username,pass:password,remember:!!remember};return this.base.postJson(loginUrl,data,opts);};OctoPrintBrowserClient.prototype.passiveLogin=function(opts){return this.base.postJson(loginUrl,{passive:true},opts);};OctoPrintBrowserClient.prototype.logout=function(opts){return this.base.postJson(logoutUrl,{},opts);};OctoPrintClient.registerComponent("browser",OctoPrintBrowserClient);return OctoPrintBrowserClient;});
;
// source: js/app/client/connection.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/connection";var OctoPrintConnectionClient=function(base){this.base=base;};OctoPrintConnectionClient.prototype.getSettings=function(opts){return this.base.get(url,opts);};OctoPrintConnectionClient.prototype.connect=function(data,opts){return this.base.issueCommand(url,"connect",data||{},opts);};OctoPrintConnectionClient.prototype.disconnect=function(opts){return this.base.issueCommand(url,"disconnect",{},opts);};OctoPrintConnectionClient.prototype.fakeAck=function(opts){return this.base.issueCommand(url,"fake_ack",{},opts);};OctoPrintClient.registerComponent("connection",OctoPrintConnectionClient);return OctoPrintConnectionClient;});
;
// source: js/app/client/control.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var customUrl="api/printer/command/custom";var commandUrl="api/printer/command";var OctoPrintControlClient=function(base){this.base=base;};OctoPrintControlClient.prototype.getCustomControls=function(opts){return this.base.get(customUrl,opts);};OctoPrintControlClient.prototype.sendGcodeWithParameters=function(commands,parameters,opts){commands=commands||[];parameters=parameters||{};if(typeof commands==="string"){commands=[commands];}
return this.base.postJson(commandUrl,{commands:commands,parameters:parameters},opts);};OctoPrintControlClient.prototype.sendGcodeScriptWithParameters=function(script,context,parameters,opts){script=script||"";context=context||{};parameters=parameters||{};return this.base.postJson(commandUrl,{script:script,context:context,parameters:parameters},opts);};OctoPrintControlClient.prototype.sendGcode=function(commands,opts){return this.sendGcodeWithParameters(commands,undefined,opts);};OctoPrintControlClient.prototype.sendGcodeScript=function(script,context,opts){return this.sendGcodeScriptWithParameters(script,context,undefined,opts);};OctoPrintClient.registerComponent("control",OctoPrintControlClient);return OctoPrintControlClient;});
;
// source: js/app/client/files.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery","lodash"],factory);}else{factory(global.OctoPrintClient,global.$,global._);}})(this,function(OctoPrintClient,$,_){var url="api/files";var downloadUrl="downloads/files";var testUrl=url+"/test";var OctoPrintFilesClient=function(base){this.base=base;};var resourceForLocation=function(location){return url+"/"+OctoPrintClient.escapePath(location);};var downloadForLocation=function(location){return downloadUrl+"/"+OctoPrintClient.escapePath(location);};var downloadForEntry=function(location,filename){return downloadForLocation(location)+"/"+OctoPrintClient.escapePath(filename);};var resourceForEntry=function(location,filename){return resourceForLocation(location)+"/"+OctoPrintClient.escapePath(filename);};var preProcessList=function(response){var recursiveCheck=function(element,index,list){if(!element.hasOwnProperty("parent"))
element.parent={children:list,parent:undefined};if(!element.hasOwnProperty("size"))element.size=undefined;if(!element.hasOwnProperty("date"))element.date=undefined;if(element.type=="folder"){element.weight=0;_.each(element.children,function(e,i,l){e.parent=element;recursiveCheck(e,i,l);element.weight+=e.weight;});}else{element.weight=1;}};_.each(response.files,recursiveCheck);};OctoPrintFilesClient.prototype.get=function(location,entryname,opts){return this.base.get(resourceForEntry(location,entryname),opts);};OctoPrintFilesClient.prototype.list=function(recursively,force,opts){recursively=recursively||false;force=force||false;var query={};if(recursively){query.recursive=recursively;}
if(force){query.force=force;}
return this.base.getWithQuery(url,query,opts).done(preProcessList);};OctoPrintFilesClient.prototype.listForLocation=function(location,recursively,opts){recursively=recursively||false;return this.base.getWithQuery(resourceForLocation(location),{recursive:recursively},opts).done(preProcessList);};OctoPrintFilesClient.prototype.issueEntryCommand=function(location,entryname,command,data,opts){var url=resourceForEntry(location,entryname);return this.base.issueCommand(url,command,data,opts);};OctoPrintFilesClient.prototype.select=function(location,path,print,opts){print=print||false;var data={print:print};return this.issueEntryCommand(location,path,"select",data,opts);};OctoPrintFilesClient.prototype.analyse=function(location,path,parameters,opts){return this.issueEntryCommand(location,path,"analyse",parameters||{},opts);};OctoPrintFilesClient.prototype.slice=function(location,path,parameters,opts){return this.issueEntryCommand(location,path,"slice",parameters||{},opts);};OctoPrintFilesClient.prototype.delete=function(location,path,opts){return this.base.delete(resourceForEntry(location,path),opts);};OctoPrintFilesClient.prototype.copy=function(location,path,destination,opts){return this.issueEntryCommand(location,path,"copy",{destination:destination},opts);};OctoPrintFilesClient.prototype.move=function(location,path,destination,opts){return this.issueEntryCommand(location,path,"move",{destination:destination},opts);};OctoPrintFilesClient.prototype.createFolder=function(location,name,path,opts){var data={foldername:name};if(path!==undefined&&path!==""){data.path=path;}
return this.base.postForm(resourceForLocation(location),data,opts);};OctoPrintFilesClient.prototype.upload=function(location,file,data){data=data||{};var filename=data.filename||undefined;if(data.userdata&&typeof data.userdata==="object"){data.userdata=JSON.stringify(userdata);}
return this.base.upload(resourceForLocation(location),file,filename,data);};OctoPrintFilesClient.prototype.download=function(location,path,opts){return this.base.download(downloadForEntry(location,path),opts);};OctoPrintFilesClient.prototype.downloadPath=function(location,path){var url=downloadForEntry(location,path);if(!_.startsWith(url,"http://")&&!_.startsWith(url,"https://")){url=this.base.getBaseUrl()+url;}
return url;};OctoPrintFilesClient.prototype.pathForEntry=function(entry){if(!entry||!entry.hasOwnProperty("parent")||entry.parent==undefined){return"";}
var recursivePath=function(element,path){if(element.hasOwnProperty("parent")&&element.parent!=undefined){return recursivePath(element.parent,element.name+"/"+path);}
return path;};return recursivePath(entry.parent,entry.name);};OctoPrintFilesClient.prototype.entryForPath=function(path,root){if(_.isArray(root)){root={children:root};}
var recursiveSearch=function(path,entry){if(path.length==0){return entry;}
if(!entry.hasOwnProperty("children")||!entry.children){return undefined;}
var name=path.shift();for(var i=0;i<entry.children.length;i++){if(name==entry.children[i].name){return recursiveSearch(path,entry.children[i]);}}
return undefined;};return recursiveSearch(path.split("/"),root);};OctoPrintFilesClient.prototype.sanitize=function(location,path,filename,opts){return this.base.issueCommand(testUrl,"sanitize",{storage:location,path:path,filename:filename},opts);};OctoPrintFilesClient.prototype.exists=function(location,path,filename,opts){return this.base.issueCommand(testUrl,"exists",{storage:location,path:path,filename:filename},opts);};OctoPrintClient.registerComponent("files",OctoPrintFilesClient);return OctoPrintFilesClient;});
;
// source: js/app/client/job.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/job";var OctoPrintJobClient=function(base){this.base=base;};OctoPrintJobClient.prototype.issueCommand=function(command,payload,opts){if(arguments.length==2){opts=payload;payload={};}
return this.base.issueCommand(url,command,payload,opts);};OctoPrintJobClient.prototype.get=function(opts){return OctoPrint.get(url,opts);};OctoPrintJobClient.prototype.start=function(opts){return this.issueCommand("start",opts);};OctoPrintJobClient.prototype.restart=function(opts){return this.issueCommand("restart",opts);};OctoPrintJobClient.prototype.pause=function(opts){return this.issueCommand("pause",{action:"pause"},opts);};OctoPrintJobClient.prototype.resume=function(opts){return this.issueCommand("pause",{action:"resume"},opts);};OctoPrintJobClient.prototype.togglePause=function(opts){return this.issueCommand("pause",{action:"toggle"},opts);};OctoPrintJobClient.prototype.cancel=function(opts){return this.issueCommand("cancel",opts);};OctoPrintClient.registerComponent("job",OctoPrintJobClient);return OctoPrintJobClient;});
;
// source: js/app/client/languages.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/languages";var OctoPrintLanguagesClient=function(base){this.base=base;};OctoPrintLanguagesClient.prototype.list=function(opts){return this.base.get(url,opts);};OctoPrintLanguagesClient.prototype.upload=function(file){return this.base.upload(url,file);};OctoPrintLanguagesClient.prototype.delete=function(locale,pack,opts){var packUrl=url+"/"+locale+"/"+pack;return this.base.delete(packUrl,opts);};OctoPrintClient.registerComponent("languages",OctoPrintLanguagesClient);return OctoPrintLanguagesClient;});
;
// source: js/app/client/printer.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/printer";var printheadUrl=url+"/printhead";var toolUrl=url+"/tool";var bedUrl=url+"/bed";var chamberUrl=url+"/chamber";var sdUrl=url+"/sd";var errorUrl=url+"/error";var OctoPrintPrinterClient=function(base){this.base=base;};OctoPrintPrinterClient.prototype.issuePrintheadCommand=function(command,payload,opts){return this.base.issueCommand(printheadUrl,command,payload,opts);};OctoPrintPrinterClient.prototype.issueToolCommand=function(command,payload,opts){return this.base.issueCommand(toolUrl,command,payload,opts);};OctoPrintPrinterClient.prototype.issueBedCommand=function(command,payload,opts){return this.base.issueCommand(bedUrl,command,payload,opts);};OctoPrintPrinterClient.prototype.issueChamberCommand=function(command,payload,opts){return this.base.issueCommand(chamberUrl,command,payload,opts);};OctoPrintPrinterClient.prototype.issueSdCommand=function(command,payload,opts){return this.base.issueCommand(sdUrl,command,payload,opts);};OctoPrintPrinterClient.prototype.getFullState=function(flags,opts){flags=flags||{};var history=flags.history||undefined;var limit=flags.limit||undefined;var exclude=flags.exclude||undefined;var getUrl=url;if(history||exclude){getUrl+="?";if(history){getUrl+="history=true&";if(limit){getUrl+="limit="+limit+"&";}}
if(exclude){getUrl+="exclude="+exclude.join(",")+"&";}}
return this.base.get(getUrl,opts);};OctoPrintPrinterClient.prototype.getToolState=function(flags,opts){flags=flags||{};var history=flags.history||undefined;var limit=flags.limit||undefined;var getUrl=toolUrl;if(history){getUrl+="?history=true";if(limit){getUrl+="&limit="+limit;}}
return this.base.get(getUrl,opts);};OctoPrintPrinterClient.prototype.getBedState=function(flags,opts){flags=flags||{};var history=flags.history||undefined;var limit=flags.limit||undefined;var getUrl=bedUrl;if(history){getUrl+="?history=true";if(limit){getUrl+="&limit="+limit;}}
return this.base.get(getUrl,opts);};OctoPrintPrinterClient.prototype.getChamberState=function(flags,opts){flags=flags||{};var history=flags.history||undefined;var limit=flags.limit||undefined;var getUrl=chamberUrl;if(history){getUrl+="?history=true";if(limit){getUrl+="&limit="+limit;}}
return this.base.get(getUrl,opts);};OctoPrintPrinterClient.prototype.getSdState=function(opts){return this.base.get(sdUrl,opts);};OctoPrintPrinterClient.prototype.getErrorInfo=function(opts){return this.base.get(errorUrl,opts);};OctoPrintPrinterClient.prototype.jog=function(params,opts){params=params||{};var absolute=params.absolute||false;var payload={absolute:absolute};if(params.x)payload.x=params.x;if(params.y)payload.y=params.y;if(params.z)payload.z=params.z;if(params.speed!==undefined)payload.speed=params.speed;return this.issuePrintheadCommand("jog",payload,opts);};OctoPrintPrinterClient.prototype.home=function(axes,opts){axes=axes||[];var payload={axes:axes};return this.issuePrintheadCommand("home",payload,opts);};OctoPrintPrinterClient.prototype.setFeedrate=function(factor,opts){factor=factor||100;var payload={factor:factor};return this.issuePrintheadCommand("feedrate",payload,opts);};OctoPrintPrinterClient.prototype.setToolTargetTemperatures=function(targets,opts){targets=targets||{};var payload={targets:targets};return this.issueToolCommand("target",payload,opts);};OctoPrintPrinterClient.prototype.setToolTemperatureOffsets=function(offsets,opts){offsets=offsets||{};var payload={offsets:offsets};return this.issueToolCommand("offset",payload,opts);};OctoPrintPrinterClient.prototype.selectTool=function(tool,opts){tool=tool||undefined;var payload={tool:tool};return this.issueToolCommand("select",payload,opts);};OctoPrintPrinterClient.prototype.extrude=function(amount,opts){amount=amount||undefined;var payload={amount:amount};return this.issueToolCommand("extrude",payload,opts);};OctoPrintPrinterClient.prototype.setFlowrate=function(factor,opts){factor=factor||100;var payload={factor:factor};return this.issueToolCommand("flowrate",payload,opts);};OctoPrintPrinterClient.prototype.setBedTargetTemperature=function(target,opts){target=target||0;var payload={target:target};return this.issueBedCommand("target",payload,opts);};OctoPrintPrinterClient.prototype.setBedTemperatureOffset=function(offset,opts){offset=offset||0;var payload={offset:offset};return this.issueBedCommand("offset",payload,opts);};OctoPrintPrinterClient.prototype.setChamberTargetTemperature=function(target,opts){target=target||0;var payload={target:target};return this.issueChamberCommand("target",payload,opts);};OctoPrintPrinterClient.prototype.setChamberTemperatureOffset=function(offset,opts){offset=offset||0;var payload={offset:offset};return this.issueChamberCommand("offset",payload,opts);};OctoPrintPrinterClient.prototype.initSd=function(opts){return this.issueSdCommand("init",{},opts);};OctoPrintPrinterClient.prototype.refreshSd=function(opts){return this.issueSdCommand("refresh",{},opts);};OctoPrintPrinterClient.prototype.releaseSd=function(opts){return this.issueSdCommand("release",{},opts);};OctoPrintClient.registerComponent("printer",OctoPrintPrinterClient);return OctoPrintPrinterClient;});
;
// source: js/app/client/printerprofiles.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery"],factory);}else{factory(global.OctoPrintClient,global.$);}})(this,function(OctoPrintClient,$){var url="api/printerprofiles";var profileUrl=function(profile){return url+"/"+profile;};var OctoPrintPrinterProfileClient=function(base){this.base=base;};OctoPrintPrinterProfileClient.prototype.list=function(opts){return this.base.get(url,opts);};OctoPrintPrinterProfileClient.prototype.add=function(profile,basedOn,opts){profile=profile||{};var data={profile:profile};if(basedOn){data.basedOn=basedOn;}
return this.base.postJson(url,data,opts);};OctoPrintPrinterProfileClient.prototype.get=function(id,opts){return this.base.get(profileUrl(id),opts);};OctoPrintPrinterProfileClient.prototype.update=function(id,profile,opts){profile=profile||{};var data={profile:profile};return this.base.patchJson(profileUrl(id),data,opts);};OctoPrintPrinterProfileClient.prototype.delete=function(id,opts){return this.base.delete(profileUrl(id),opts);};OctoPrintClient.registerComponent("printerprofiles",OctoPrintPrinterProfileClient);return OctoPrintPrinterProfileClient;});
;
// source: js/app/client/settings.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery"],factory);}else{factory(global.OctoPrintClient,global.$);}})(this,function(OctoPrintClient,$){var url="api/settings";var apiKeyUrl=url+"/apikey";var OctoPrintSettingsClient=function(base){this.base=base;};OctoPrintSettingsClient.prototype.get=function(opts){return this.base.get(url,opts);};OctoPrintSettingsClient.prototype.save=function(settings,opts){settings=settings||{};return this.base.postJson(url,settings,opts);};OctoPrintSettingsClient.prototype.getPluginSettings=function(plugin,opts){return this.get(opts).then(function(settings,statusText,request){if(!settings.plugins||!settings.plugins[plugin]){return $.Deferred().reject(request,"dataerror","No settings for plugin "+plugin).promise();}else{return settings.plugins[plugin];}});};OctoPrintSettingsClient.prototype.savePluginSettings=function(plugin,settings,opts){var data={};data["plugins"]={};data["plugins"][plugin]=settings;return this.save(data,opts);};OctoPrintSettingsClient.prototype.generateApiKey=function(opts){return this.base.postJson(apiKeyUrl,opts);};OctoPrintSettingsClient.prototype.deleteApiKey=function(opts){return this.base.delete(apiKeyUrl,opts);};OctoPrintClient.registerComponent("settings",OctoPrintSettingsClient);return OctoPrintSettingsClient;});
;
// source: js/app/client/slicing.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/slicing";var slicerUrl=function(slicer){return url+"/"+slicer;};var profileUrl=function(slicer,profileId){return slicerUrl(slicer)+"/profiles/"+profileId;};var OctoPrintSlicingClient=function(base){this.base=base;};OctoPrintSlicingClient.prototype.listAllSlicersAndProfiles=function(opts){return this.base.get(url,opts);};OctoPrintSlicingClient.prototype.listProfilesForSlicer=function(slicer,opts){return this.base.get(slicerUrl(slicer)+"/profiles",opts);};OctoPrintSlicingClient.prototype.getProfileForSlicer=function(slicer,profileId,opts){return this.base.get(profileUrl(slicer,profileId),opts);};OctoPrintSlicingClient.prototype.addProfileForSlicer=function(slicer,profileId,profile,opts){profile=profile||{};return this.base.putJson(profileUrl(slicer,profileId),profile,opts);};OctoPrintSlicingClient.prototype.updateProfileForSlicer=function(slicer,profileId,profile,opts){profile=profile||{};return this.base.patchJson(profileUrl(slicer,profileId),profile,opts);};OctoPrintSlicingClient.prototype.deleteProfileForSlicer=function(slicer,profileId,opts){return this.base.delete(profileUrl(slicer,profileId),opts);};OctoPrintClient.registerComponent("slicing",OctoPrintSlicingClient);return OctoPrintSlicingClient;});
;
// source: js/app/client/system.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/system";var commandUrl="api/system/commands";var infoUrl="api/system/info";var startupUrl="api/system/startup";var OctoPrintSystemClient=function(base){this.base=base;};OctoPrintSystemClient.prototype.getCommands=function(opts){return this.base.get(commandUrl,opts);};OctoPrintSystemClient.prototype.getCommandsForSource=function(source,opts){return this.base.get(commandUrl+"/"+source,opts);};OctoPrintSystemClient.prototype.executeCommand=function(source,action,opts){return this.base.postJson(commandUrl+"/"+source+"/"+action,{},opts);};OctoPrintSystemClient.prototype.getInfo=function(opts){return this.base.get(infoUrl,opts);};OctoPrintSystemClient.prototype.getStartupData=function(opts){return this.base.get(startupUrl,opts);};OctoPrintClient.registerComponent("system",OctoPrintSystemClient);return OctoPrintSystemClient;});
;
// source: js/app/client/timelapse.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery"],factory);}else{factory(global.OctoPrintClient,global.$);}})(this,function(OctoPrintClient,$){var url="api/timelapse";var downloadUrl="downloads/timelapse";var bulkDownloadUrl="downloads/timelapses";var timelapseUrl=function(filename){return url+"/"+OctoPrintClient.escapePath(filename);};var timelapseDownloadUrl=function(filename){return downloadUrl+"/"+OctoPrintClient.escapePath(filename);};var unrenderedTimelapseUrl=function(name){return url+"/unrendered/"+OctoPrintClient.escapePath(name);};var OctoPrintTimelapseClient=function(base){this.base=base;};OctoPrintTimelapseClient.prototype.get=function(unrendered,opts){if(unrendered){opts=opts||{};opts.data={unrendered:unrendered};}
return this.base.get(url,opts);};OctoPrintTimelapseClient.prototype.list=function(opts){var deferred=$.Deferred();this.get(true,opts).done(function(response,status,request){deferred.resolve({rendered:response.files,unrendered:response.unrendered},status,request);}).fail(function(){deferred.reject.apply(null,arguments);});return deferred.promise();};OctoPrintTimelapseClient.prototype.listRendered=function(opts){var deferred=$.Deferred();this.get(false,opts).done(function(response,status,request){deferred.resolve(response.files,status,request);}).fail(function(){deferred.reject.apply(null,arguments);});return deferred.promise();};OctoPrintTimelapseClient.prototype.listUnrendered=function(opts){var deferred=$.Deferred();this.get(true,opts).done(function(response,status,request){deferred.resolve(response.unrendered,status,request);}).fail(function(){deferred.reject.apply(null,arguments);});return deferred.promise();};OctoPrintTimelapseClient.prototype.download=function(filename,opts){return this.base.download(timelapseDownloadUrl(filename),opts);};OctoPrintTimelapseClient.prototype.bulkDownloadUrl=function(filenames){return this.base.bulkDownloadUrl(bulkDownloadUrl,filenames);};OctoPrintTimelapseClient.prototype.delete=function(filename,opts){return this.base.delete(timelapseUrl(filename),opts);};OctoPrintTimelapseClient.prototype.deleteUnrendered=function(name,opts){return this.base.delete(unrenderedTimelapseUrl(name),opts);};OctoPrintTimelapseClient.prototype.renderUnrendered=function(name,opts){return this.base.issueCommand(unrenderedTimelapseUrl(name),"render");};OctoPrintTimelapseClient.prototype.getConfig=function(opts){var deferred=$.Deferred();this.get(false,opts).done(function(response,status,request){deferred.resolve(response.config,status,request);}).fail(function(){deferred.reject.apply(null,arguments);});return deferred.promise();};OctoPrintTimelapseClient.prototype.saveConfig=function(config,opts){config=config||{};return OctoPrint.postJson(url,config,opts);};OctoPrintClient.registerComponent("timelapse",OctoPrintTimelapseClient);return OctoPrintTimelapseClient;});
;
// source: js/app/client/users.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","OctoPrintAccessClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var deprecatedUserClient=function(deprecatedFct,newFct,fn){return OctoPrintClient.deprecated("OctoPrint.users."+deprecatedFct,"OctoPrint.access.users."+newFct,fn);};var OctoPrintUserClient=function(base){this.base=base;};OctoPrintUserClient.prototype.list=deprecatedUserClient("list","list",function(opts){return this.base.access.users.list(opts);});OctoPrintUserClient.prototype.add=deprecatedUserClient("add","add",function(user,opts){return this.base.access.users.add(user,opts);});OctoPrintUserClient.prototype.get=deprecatedUserClient("get","get",function(name,opts){return this.base.access.users.get(name,opts);});OctoPrintUserClient.prototype.update=deprecatedUserClient("update","update",function(name,active,admin,permissions,groups,opts){return this.base.access.users.update(name,active,admin,permissions,groups,opts);});OctoPrintUserClient.prototype.delete=deprecatedUserClient("delete","delete",function(name,opts){return this.base.access.users.delete(name,opts);});OctoPrintUserClient.prototype.changePassword=deprecatedUserClient("changePassword","changePassword",function(name,password,opts){return this.base.access.users.changePassword(name,password,opts);});OctoPrintUserClient.prototype.generateApiKey=deprecatedUserClient("generateApiKey","generateApiKey",function(name,opts){return this.base.access.users.generateApiKey(name,opts);});OctoPrintUserClient.prototype.resetApiKey=deprecatedUserClient("resetApiKey","resetApiKey",function(name,opts){return this.base.access.users.resetApiKey(name,opts);});OctoPrintUserClient.prototype.getSettings=deprecatedUserClient("getSettings","getSettings",function(name,opts){return this.base.access.users.getSettings(name,opts);});OctoPrintUserClient.prototype.saveSettings=deprecatedUserClient("saveSettings","saveSettings",function(name,settings,opts){return this.base.access.users.saveSettings(name,settings,opts);});OctoPrintClient.registerComponent("users",OctoPrintUserClient);return OctoPrintUserClient;});
;
// source: js/app/client/util.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient","jquery"],factory);}else{factory(global.OctoPrintClient,global.$);}})(this,function(OctoPrint,$){var url="api/util";var testUrl=url+"/test";var OctoPrintUtilClient=function(base){this.base=base;};OctoPrintUtilClient.prototype.test=function(command,parameters,opts){return this.base.issueCommand(testUrl,command,parameters,opts);};OctoPrintUtilClient.prototype.testPath=function(path,additional,opts){additional=additional||{};var data=$.extend({},additional);data.path=path;return this.test("path",data,opts);};OctoPrintUtilClient.prototype.testExecutable=function(path,additional,opts){additional=additional||{};var data=$.extend({},additional);data.path=path;data.check_type="file";data.check_access="x";return this.test("path",data,opts);};OctoPrintUtilClient.prototype.testUrl=function(url,additional,opts){additional=additional||{};var data=$.extend({},additional);data.url=url;return this.test("url",data,opts);};OctoPrintUtilClient.prototype.testServer=function(host,port,additional,opts){additional=additional||{};var data=$.extend({},additional);data.host=host;data.port=port;return this.test("server",data,opts);};OctoPrintUtilClient.prototype.testResolution=function(name,additional,opts){additional=additional||{};var data=$.extend({},additional);data.name=name;return this.test("resolution",data,opts);};OctoPrintUtilClient.prototype.testAddress=function(address,additional,opts){additional=additional||{};var data=$.extend({},additional);data.address=address;return this.test("address",data,opts);};OctoPrintClient.registerComponent("util",OctoPrintUtilClient);return OctoPrintUtilClient;});
;
// source: js/app/client/wizard.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var url="api/setup/wizard";var OctoPrintWizardClient=function(base){this.base=base;};OctoPrintWizardClient.prototype.get=function(opts){return this.base.get(url,opts);};OctoPrintWizardClient.prototype.finish=function(handled,opts){return this.base.postJson(url,{handled:handled||[]},opts);};OctoPrintClient.registerComponent("wizard",OctoPrintWizardClient);return OctoPrintWizardClient;});
;
// source: plugin/achievements/clientjs/achievements.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintAchievementsClient=function(base){this.base=base;this.baseUrl=this.base.getBlueprintUrl("achievements");};OctoPrintAchievementsClient.prototype.get=function(opts){return this.base.get(this.baseUrl,opts);};OctoPrintAchievementsClient.prototype.getYear=function(year,opts){return this.base.get(this.baseUrl+"/year/"+year,opts);};OctoPrintClient.registerPluginComponent("achievements",OctoPrintAchievementsClient);return OctoPrintAchievementsClient;});
;
// source: plugin/action_command_notification/clientjs/action_command_notification.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintActionCommandNotificationClient=function(base){this.base=base;};OctoPrintActionCommandNotificationClient.prototype.get=function(refresh,opts){return this.base.get(this.base.getSimpleApiUrl("action_command_notification"),opts);};OctoPrintActionCommandNotificationClient.prototype.clear=function(opts){return this.base.simpleApiCommand("action_command_notification","clear",{},opts);};OctoPrintClient.registerPluginComponent("action_command_notification",OctoPrintActionCommandNotificationClient);return OctoPrintActionCommandNotificationClient;});
;
// source: plugin/action_command_prompt/clientjs/action_command_prompt.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintActionCommandPromptClient=function(base){this.base=base;};OctoPrintActionCommandPromptClient.prototype.get=function(refresh,opts){return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"),opts);};OctoPrintActionCommandPromptClient.prototype.select=function(choice,opts){var data={choice:choice};return this.base.simpleApiCommand("action_command_prompt","select",data,opts);};OctoPrintClient.registerPluginComponent("action_command_prompt",OctoPrintActionCommandPromptClient);return OctoPrintActionCommandPromptClient;});
;
// source: plugin/appkeys/clientjs/appkeys.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintAppKeysClient=function(base){this.base=base;};OctoPrintAppKeysClient.prototype.getKeys=function(opts){return this.base.simpleApiGet("appkeys",opts);};OctoPrintAppKeysClient.prototype.getAllKeys=function(opts){return this.base.get(this.base.getSimpleApiUrl("appkeys")+"?all=true",opts);};OctoPrintAppKeysClient.prototype.getKey=function(app,user,opts){return this.base.get(this.base.getSimpleApiUrl("appkeys")+"?app="+
encodeURIComponent(app)+
(user?"&user="+encodeURIComponent(user):""),opts);};OctoPrintAppKeysClient.prototype.generateKey=function(app,opts){return this.base.simpleApiCommand("appkeys","generate",{app:app},opts);};OctoPrintAppKeysClient.prototype.generateKeyForUser=function(user,app,opts){return this.base.simpleApiCommand("appkeys","generate",{app:app,user:user},opts);};OctoPrintAppKeysClient.prototype.revokeKey=function(key,opts){console.log("revokeKey should be considered deprecated, use revokeKeyForApp instead");return this.base.simpleApiCommand("appkeys","revoke",{key:key},opts);};OctoPrintAppKeysClient.prototype.revokeKeyForApp=function(app,user,opts){const params={app:app};if(user){params.user=user;}
return this.base.simpleApiCommand("appkeys","revoke",params,opts);};OctoPrintAppKeysClient.prototype.decide=function(token,decision,opts){return this.base.postJson(this.base.getBlueprintUrl("appkeys")+"decision/"+token,{decision:!!decision},opts);};OctoPrintAppKeysClient.prototype.probe=function(opts){return this.base.get(this.base.getBlueprintUrl("appkeys")+"probe",opts);};OctoPrintAppKeysClient.prototype.request=function(app,opts){return this.requestForUser(app,undefined,opts);};OctoPrintAppKeysClient.prototype.requestForUser=function(app,user,opts){return this.base.postJson(this.base.getBlueprintUrl("appkeys")+"request",{app:app,user:user},opts);};OctoPrintAppKeysClient.prototype.checkDecision=function(token,opts){return this.base.get(this.base.getBlueprintUrl("appkeys")+"request/"+token,opts);};OctoPrintAppKeysClient.prototype.authenticate=function(app,user){var deferred=$.Deferred();var client=this;client.probe().done(function(){client.requestForUser(app,user).done(function(response){var token=response.app_token;if(!token){deferred.reject();return;}
var interval=1000;var poll=function(){client.checkDecision(token).done(function(response){if(response.api_key){deferred.resolve(response.api_key);}else{deferred.notify();window.setTimeout(poll,interval);}}).fail(function(){deferred.reject();});};window.setTimeout(poll,interval);}).fail(function(){deferred.reject();});}).fail(function(){deferred.reject();});return deferred.promise();};OctoPrintClient.registerPluginComponent("appkeys",OctoPrintAppKeysClient);return OctoPrintAppKeysClient;});
;
// source: plugin/backup/clientjs/backup.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintBackupClient=function(base){this.base=base;this.url=this.base.getBlueprintUrl("backup");};OctoPrintBackupClient.prototype.get=function(refresh,opts){return this.base.get(this.url,opts);};OctoPrintBackupClient.prototype.createBackup=function(exclude,opts){exclude=exclude||[];var data={exclude:exclude};return this.base.postJson(this.url+"backup",data,opts);};OctoPrintBackupClient.prototype.deleteBackup=function(backup,opts){return this.base.delete(this.url+"backup/"+backup,opts);};OctoPrintBackupClient.prototype.restoreBackup=function(backup,opts){var data={path:backup};return this.base.postJson(this.url+"restore",data,opts);};OctoPrintBackupClient.prototype.restoreBackupFromUpload=function(file,data){data=data||{};var filename=data.filename||undefined;return this.base.upload(this.url+"restore",file,filename,data);};OctoPrintBackupClient.prototype.deleteUnknownPlugins=function(opts){return this.base.delete(this.url+"unknown_plugins",opts);};OctoPrintClient.registerPluginComponent("backup",OctoPrintBackupClient);return OctoPrintBackupClient;});
;
// source: plugin/file_check/clientjs/file_check.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintFileCheckClient=function(base){this.base=base;};OctoPrintFileCheckClient.prototype.get=function(opts){return this.base.simpleApiGet("file_check",opts);};OctoPrintFileCheckClient.prototype.checkAll=function(opts){return this.base.simpleApiCommand("file_check","check_all",opts);};OctoPrintClient.registerPluginComponent("file_check",OctoPrintFileCheckClient);return OctoPrintFileCheckClient;});
;
// source: plugin/firmware_check/clientjs/firmware_check.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintFirmwareCheckClient=function(base){this.base=base;};OctoPrintFirmwareCheckClient.prototype.get=function(opts){return this.base.get(this.base.getSimpleApiUrl("firmware_check"),opts);};OctoPrintClient.registerPluginComponent("firmware_check",OctoPrintFirmwareCheckClient);return OctoPrintFirmwareCheckClient;});
;
// source: plugin/logging/clientjs/logging.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintLoggingClient=function(base){this.base=base;this.baseUrl=this.base.getBlueprintUrl("logging");this.logsUrl=this.baseUrl+"logs";this.setupUrl=this.baseUrl+"setup";};var bulkDownloadUrl="downloads/logs";OctoPrintLoggingClient.prototype.get=function(opts){return this.base.get(this.baseUrl,opts);};OctoPrintLoggingClient.prototype.listLogs=function(opts){return this.base.get(this.logsUrl,opts);};OctoPrintLoggingClient.prototype.deleteLog=function(file,opts){var fileUrl=this.logsUrl+"/"+file;return this.base.delete(fileUrl,opts);};OctoPrintLoggingClient.prototype.downloadLog=function(file,opts){var fileUrl=this.logsUrl+"/"+file;return this.base.download(fileUrl,opts);};OctoPrintLoggingClient.prototype.bulkDownloadUrl=function(filenames){return this.base.bulkDownloadUrl(bulkDownloadUrl,filenames);};OctoPrintLoggingClient.prototype.updateLevels=function(config,opts){return this.base.putJson(this.setupUrl+"/levels",config,opts);};var DeprecatedOctoPrintLogsClient=function(base){this.base=base;this.wrapped=this.base.plugins.logging;};DeprecatedOctoPrintLogsClient.prototype.list=function(opts){log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");return this.wrapped.listLogs(opts);};DeprecatedOctoPrintLogsClient.prototype.delete=function(file,opts){log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");return this.wrapped.deleteLog(file,opts);};DeprecatedOctoPrintLogsClient.prototype.download=function(file,opts){log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");return this.wrapped.downloadLog(file,opts);};OctoPrintClient.registerPluginComponent("logging",OctoPrintLoggingClient);OctoPrintClient.registerComponent("logs",DeprecatedOctoPrintLogsClient);return OctoPrintLoggingClient;});
;
// source: plugin/pluginmanager/clientjs/pluginmanager.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintPluginManagerClient=function(base){this.base=base;};OctoPrintPluginManagerClient.prototype.get=function(refresh,opts){console.log("Deprecated endpoint OctoPrint.plugin.pluginmanager.get, "+"please use OctoPrint.plugin.pluginmanager.get*");var refresh_repo,refresh_notices,refresh_orphans;if(_.isPlainObject(refresh)){refresh_repo=refresh.repo||false;refresh_notices=refresh.notices||false;refresh_orphans=refresh.orphans||false;}else{refresh_repo=refresh;refresh_notices=false;refresh_orphans=false;}
var query=[];if(refresh_repo)query.push("refresh_repository=true");if(refresh_notices)query.push("refresh_notices=true");if(refresh_orphans)query.push("refresh_orphans=true");return this.base.get(this.base.getSimpleApiUrl("pluginmanager")+
(query.length?"?"+query.join("&"):""),opts);};OctoPrintPluginManagerClient.prototype.getWithRefresh=function(opts){console.log("Deprecated endpoint OctoPrint.plugin.pluginmanager.getWithRefresh, "+"please use OctoPrint.plugin.pluginmanager.get*");return this.get(true,opts);};OctoPrintPluginManagerClient.prototype.getWithoutRefresh=function(opts){console.log("Deprecated endpoint OctoPrint.plugin.pluginmanager.getWithoutRefresh, "+"please use OctoPrint.plugin.pluginmanager.get*");return this.get(false,opts);};OctoPrintPluginManagerClient.prototype.getPlugins=function(refresh,opts){var url=this.base.getBlueprintUrl("pluginmanager")+"plugins";return this.base.get(url+(refresh?"?refresh=true":""),opts);};OctoPrintPluginManagerClient.prototype.getPlugin=function(plugin,opts){var url=this.base.getBlueprintUrl("pluginmanager")+"plugins/"+plugin;return this.base.get(url,opts);};OctoPrintPluginManagerClient.prototype.getOrphans=function(refresh,opts){var url=this.base.getBlueprintUrl("pluginmanager")+"orphans";return this.base.get(url+(refresh?"?refresh=true":""),opts);};OctoPrintPluginManagerClient.prototype.getRepository=function(refresh,opts){var url=this.base.getBlueprintUrl("pluginmanager")+"repository";return this.base.get(url+(refresh?"?refresh=true":""),opts);};OctoPrintPluginManagerClient.prototype.install=function(pluginUrl,dependencyLinks,fromRepo,opts){if(typeof fromRepo==="object"){opts=fromRepo;fromRepo=false;}
var data={url:pluginUrl,dependency_links:!!dependencyLinks,from_repo:!!fromRepo};return this.base.simpleApiCommand("pluginmanager","install",data,opts);};OctoPrintPluginManagerClient.prototype.reinstall=function(plugin,pluginUrl,dependencyLinks,fromRepo,opts){if(typeof fromRepo==="object"){opts=fromRepo;fromRepo=false;}
var data={url:pluginUrl,dependency_links:!!dependencyLinks,from_repo:!!fromRepo,reinstall:plugin,force:true};return this.base.simpleApiCommand("pluginmanager","install",data,opts);};OctoPrintPluginManagerClient.prototype.uninstall=function(plugin,cleanup,opts){if(arguments.length===2&&typeof cleanup==="object"){opts=cleanup;cleanup=false;}
var data={plugin:plugin,cleanup:!!cleanup};return this.base.simpleApiCommand("pluginmanager","uninstall",data,opts);};OctoPrintPluginManagerClient.prototype.cleanup=function(plugin,opts){var data={plugin:plugin};return this.base.simpleApiCommand("pluginmanager","cleanup",data,opts);};OctoPrintPluginManagerClient.prototype.cleanupAll=function(plugin,opts){var data={};return this.base.simpleApiCommand("pluginmanager","cleanup_all",data,opts);};OctoPrintPluginManagerClient.prototype.enable=function(plugin,opts){var data={plugin:plugin};return this.base.simpleApiCommand("pluginmanager","enable",data,opts);};OctoPrintPluginManagerClient.prototype.disable=function(plugin,opts){var data={plugin:plugin};return this.base.simpleApiCommand("pluginmanager","disable",data,opts);};OctoPrintPluginManagerClient.prototype.upload=function(file){return this.base.upload(this.base.getBlueprintUrl("pluginmanager")+"upload_archive",file);};OctoPrintClient.registerPluginComponent("pluginmanager",OctoPrintPluginManagerClient);return OctoPrintPluginManagerClient;});
;
// source: plugin/softwareupdate/clientjs/softwareupdate.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintSoftwareUpdateClient=function(base){this.base=base;var url=this.base.getBlueprintUrl("softwareupdate");this.checkUrl=url+"check";this.updateUrl=url+"update";this.configureUrl=url+"configure";this.updatelogUrl=url+"updatelog";this.queuedURL=this.updateUrl+"/queued";};OctoPrintSoftwareUpdateClient.prototype.checkEntries=function(entries,force,opts){if(arguments.length==1&&_.isObject(arguments[0])){var params=arguments[0];entries=params.entries;force=params.force;opts=params.opts;}
entries=entries||[];if(typeof entries=="string"){entries=[entries];}
var data={};if(!!force){data.force=true;}
if(entries&&entries.length){data.targets=entries.join(",");}
return this.base.getWithQuery(this.checkUrl,data,opts);};OctoPrintSoftwareUpdateClient.prototype.check=function(force,opts){if(arguments.length===1&&_.isObject(arguments[0])){var params=arguments[0];force=params.force;opts=params.opts;}
return this.checkEntries({entries:[],force:force,opts:opts});};OctoPrintSoftwareUpdateClient.prototype.update=function(targets,force,opts){if(arguments.length===1&&_.isObject(arguments[0])){var params=arguments[0];targets=params.targets;force=params.force;opts=params.opts;}
targets=targets||[];if(typeof targets==="string"){targets=[targets];}
var data={targets:targets,force:!!force};return this.base.postJson(this.updateUrl,data,opts);};OctoPrintSoftwareUpdateClient.prototype.cancelQueued=function(targets,opts){if(arguments.length===1&&_.isObject(arguments[0])){var params=arguments[0];targets=params.targets;}
targets=targets||[];if(typeof targets==="string"){targets=[targets];}
var data={command:"cancel",targets:targets};return this.base.postJson(this.queuedURL,data,opts);};OctoPrintSoftwareUpdateClient.prototype.cancelAllQueued=function(opts){if(arguments.length===1&&_.isObject(arguments[0])){var params=arguments[0];opts=params.opts;}
var data={command:"cancel"};return this.base.postJson(this.queuedURL,data,opts);};OctoPrintSoftwareUpdateClient.prototype.updateAll=function(force,opts){if(arguments.length===1&&_.isObject(arguments[0])){var params=arguments[0];force=params.force;opts=params.opts;}
var data={force:!!force};return this.base.postJson(this.updateUrl,data,opts);};OctoPrintSoftwareUpdateClient.prototype.configure=function(data,opts){return this.base.postJson(this.configureUrl,data,opts);};OctoPrintSoftwareUpdateClient.prototype.getUpdatelog=function(opts){return this.base.get(this.updatelogUrl,opts);};OctoPrintClient.registerPluginComponent("softwareupdate",OctoPrintSoftwareUpdateClient);return OctoPrintSoftwareUpdateClient;});
;
// source: plugin/tracking/clientjs/usage.js
(function(global,factory){if(typeof define==="function"&&define.amd){define(["OctoPrintClient"],factory);}else{factory(global.OctoPrintClient);}})(this,function(OctoPrintClient){var OctoPrintTrackingClient=function(base){this.base=base;};OctoPrintTrackingClient.prototype.track=function(event,payload,opts){return this.base.simpleApiCommand("tracking","track",{event:event,payload:payload},opts);};OctoPrintClient.registerPluginComponent("tracking",OctoPrintTrackingClient);return OctoPrintTrackingClient;});
;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,104 @@
// JS assets for plugin bambu_printer
(function () {
try {
// source: plugin/bambu_printer/js/bambu_printer.js
/*
* View model for OctoPrint-BambuPrinter
*
* Author: jneilliii
* License: AGPLv3
*/
$(function () {
function Bambu_printerViewModel(parameters) {
var self = this;
self.settingsViewModel = parameters[0];
self.filesViewModel = parameters[1];
self.getAuthToken = function (data) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token("");
OctoPrint.simpleApiCommand("bambu_printer", "register", {
"email": self.settingsViewModel.settings.plugins.bambu_printer.email(),
"password": $("#bambu_cloud_password").val(),
"region": self.settingsViewModel.settings.plugins.bambu_printer.region(),
"auth_token": self.settingsViewModel.settings.plugins.bambu_printer.auth_token()
})
.done(function (response) {
console.log(response);
self.settingsViewModel.settings.plugins.bambu_printer.auth_token(response.auth_token);
self.settingsViewModel.settings.plugins.bambu_printer.username(response.username);
});
};
/*$('#files div.upload-buttons > span.fileinput-button:first, #files div.folder-button').remove();
$('#files div.upload-buttons > span.fileinput-button:first').removeClass('span6').addClass('input-block-level');
self.onBeforePrintStart = function(start_print_command) {
let confirmation_html = '' +
' <div class="row-fluid form-vertical">\n' +
' <div class="control-group">\n' +
' <label class="control-label">' + gettext("Plate Number") + '</label>\n' +
' <div class="controls">\n' +
' <input type="number" min="1" value="1" id="bambu_printer_plate_number" class="input-mini">\n' +
' </div>\n' +
' </div>\n' +
' </div>';
if(!self.settingsViewModel.settings.plugins.bambu_printer.always_use_default_options()){
confirmation_html += '\n' +
' <div class="row-fluid">\n' +
' <div class="span6">\n' +
' <label class="checkbox"><input id="bambu_printer_timelapse" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.timelapse()) ? ' checked' : '') + '> ' + gettext("Enable timelapse") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_bed_leveling" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.bed_leveling()) ? ' checked' : '') + '> ' + gettext("Enable bed leveling") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_flow_cali" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.flow_cali()) ? ' checked' : '') + '> ' + gettext("Enable flow calibration") + '</label>\n' +
' </div>\n' +
' <div class="span6">\n' +
' <label class="checkbox"><input id="bambu_printer_vibration_cali" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.vibration_cali()) ? ' checked' : '') + '> ' + gettext("Enable vibration calibration") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_layer_inspect" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.layer_inspect()) ? ' checked' : '') + '> ' + gettext("Enable first layer inspection") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_use_ams" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.use_ams()) ? ' checked' : '') + '> ' + gettext("Use AMS") + '</label>\n' +
' </div>\n' +
' </div>\n';
}
showConfirmationDialog({
title: "Bambu Print Options",
html: confirmation_html,
cancel: gettext("Cancel"),
proceed: [gettext("Print"), gettext("Always")],
onproceed: function (idx) {
if(idx === 1){
self.settingsViewModel.settings.plugins.bambu_printer.timelapse($('#bambu_printer_timelapse').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.bed_leveling($('#bambu_printer_bed_leveling').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.flow_cali($('#bambu_printer_flow_cali').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.vibration_cali($('#bambu_printer_vibration_cali').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.layer_inspect($('#bambu_printer_layer_inspect').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.use_ams($('#bambu_printer_use_ams').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.always_use_default_options(true);
self.settingsViewModel.saveData();
}
// replace this with our own print command API call?
start_print_command();
},
nofade: true
});
return false;
};*/
}
OCTOPRINT_VIEWMODELS.push({
construct: Bambu_printerViewModel,
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
dependencies: ["settingsViewModel", "filesViewModel"],
// Elements to bind to, e.g. #settings_plugin_bambu_printer, #tab_plugin_bambu_printer, ...
elements: ["#bambu_printer_print_options", "#settings_plugin_bambu_printer"]
});
});
;
} catch (error) {
log.error("Error in JS assets for plugin bambu_printer:", `${exc.message}
${exc.stack || exc}`);
}
})();

View File

@ -0,0 +1,3 @@
2024-05-09 09:05:40,718 - Logging in user shxadmiral from 172.24.0.1 via credentials
2024-05-09 11:16:37,888 - Logging in user shxadmiral from 172.24.0.1 via credentials
2024-05-09 11:53:50,286 - Logging in user shxadmiral from 172.24.0.1 via credentials

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
2024-05-09 11:16:56,344 /usr/local/bin/python -m pip --disable-pip-version-check install file:///tmp/tmpfjd_ciah/OctoPrint-BambuPrinter-master.zip --no-cache-dir
2024-05-09 11:16:59,154 > Processing /tmp/tmpfjd_ciah/OctoPrint-BambuPrinter-master.zip
2024-05-09 11:16:59,155 > Preparing metadata (setup.py): started
2024-05-09 11:16:59,155 > Preparing metadata (setup.py): finished with status 'done'
2024-05-09 11:16:59,155 > Requirement already satisfied: OctoPrint in /usr/local/lib/python3.10/site-packages (from OctoPrint-BambuPrinter==0.0.18) (1.10.0)
2024-05-09 11:16:59,156 > Collecting paho-mqtt<2
2024-05-09 11:16:59,156 > Downloading paho-mqtt-1.6.1.tar.gz (99 kB)
2024-05-09 11:16:59,156 > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.4/99.4 kB 13.2 MB/s eta 0:00:00
2024-05-09 11:16:59,156 > Preparing metadata (setup.py): started
2024-05-09 11:16:59,156 > Preparing metadata (setup.py): finished with status 'done'
2024-05-09 11:16:59,156 > Collecting python-dateutil
2024-05-09 11:16:59,156 > Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
2024-05-09 11:16:59,156 > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB 103.5 MB/s eta 0:00:00
2024-05-09 11:16:59,156 > Collecting pybambu>=1.0.1
2024-05-09 11:16:59,156 > Downloading pybambu-1.0.1-py3-none-any.whl (25 kB)
2024-05-09 11:16:59,156 > Requirement already satisfied: argon2-cffi>=23.1.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (23.1.0)
2024-05-09 11:16:59,156 > Requirement already satisfied: sentry-sdk<2,>=1.40.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.45.0)
2024-05-09 11:16:59,156 > Requirement already satisfied: flask<2.3,>=2.2.3 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.2.5)
2024-05-09 11:16:59,156 > Requirement already satisfied: passlib<2,>=1.7.4 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.7.4)
2024-05-09 11:16:59,157 > Requirement already satisfied: filetype<2,>=1.2.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.2.0)
2024-05-09 11:16:59,157 > Requirement already satisfied: OctoPrint-FirmwareCheck>=2021.10.11 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2021.10.11)
2024-05-09 11:16:59,157 > Requirement already satisfied: pathvalidate<3,>=2.5.2 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.5.2)
2024-05-09 11:16:59,157 > Requirement already satisfied: frozendict<3,>=2.4.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.4.2)
2024-05-09 11:16:59,157 > Requirement already satisfied: watchdog<3,>=2.3.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.3.1)
2024-05-09 11:16:59,157 > Requirement already satisfied: pylru<2,>=1.2.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.2.1)
2024-05-09 11:16:59,157 > Requirement already satisfied: OctoPrint-FileCheck>=2021.2.23 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2024.3.27)
2024-05-09 11:16:59,157 > Requirement already satisfied: Click<9,>=8.1.7 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (8.1.7)
2024-05-09 11:16:59,157 > Requirement already satisfied: netifaces2<0.1,>=0.0.21 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.0.22)
2024-05-09 11:16:59,157 > Requirement already satisfied: Flask-Assets<3,>=2.1.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.1.0)
2024-05-09 11:16:59,157 > Requirement already satisfied: OctoPrint-PiSupport>=2023.10.10 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2023.10.10)
2024-05-09 11:16:59,157 > Requirement already satisfied: zeroconf~=0.127 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.132.2)
2024-05-09 11:16:59,157 > Requirement already satisfied: blinker<1.7.0,>=1.6.3 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.6.3)
2024-05-09 11:16:59,157 > Requirement already satisfied: unidecode in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.3.8)
2024-05-09 11:16:59,157 > Requirement already satisfied: pytz in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2024.1)
2024-05-09 11:16:59,157 > Requirement already satisfied: Babel<2.13,>=2.12.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.12.1)
2024-05-09 11:16:59,157 > Requirement already satisfied: zipstream-ng<2.0.0,>=1.7.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.7.1)
2024-05-09 11:16:59,157 > Requirement already satisfied: wheel in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.43.0)
2024-05-09 11:16:59,157 > Requirement already satisfied: Flask-Login<0.7,>=0.6.3 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.6.3)
2024-05-09 11:16:59,157 > Requirement already satisfied: pyserial<4,>=3.5 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.5)
2024-05-09 11:16:59,157 > Requirement already satisfied: future<1,>=0.18.3 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.18.3)
2024-05-09 11:16:59,157 > Requirement already satisfied: pkginfo<2,>=1.9.6 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.10.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: markdown<3.5,>=3.4.4 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.4.4)
2024-05-09 11:16:59,158 > Requirement already satisfied: sarge==0.1.7.post1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.1.7.post1)
2024-05-09 11:16:59,158 > Requirement already satisfied: colorlog<7,>=6.7.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (6.8.2)
2024-05-09 11:16:59,158 > Requirement already satisfied: emoji<3,>=2.10.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.11.1)
2024-05-09 11:16:59,158 > Requirement already satisfied: feedparser<7,>=6.0.11 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (6.0.11)
2024-05-09 11:16:59,158 > Requirement already satisfied: websocket-client==1.6.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.6.1)
2024-05-09 11:16:59,158 > Requirement already satisfied: tornado<6.3,>=6.2 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (6.2)
2024-05-09 11:16:59,158 > Requirement already satisfied: pydantic==1.10.12 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.10.12)
2024-05-09 11:16:59,158 > Requirement already satisfied: Flask-Babel<4,>=3.1.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.1.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: werkzeug<2.3,>=2.2.3 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.2.3)
2024-05-09 11:16:59,158 > Requirement already satisfied: requests<3,>=2.31.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.31.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: wrapt<1.16,>=1.15 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.15.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: PyYAML<7,>=6.0.1 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (6.0.1)
2024-05-09 11:16:59,158 > Requirement already satisfied: psutil<6,>=5.9.8 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (5.9.8)
2024-05-09 11:16:59,158 > Requirement already satisfied: class-doc<0.3,>=0.2.6 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.2.6)
2024-05-09 11:16:59,158 > Requirement already satisfied: cachelib<0.11,>=0.10.2 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.10.2)
2024-05-09 11:16:59,158 > Requirement already satisfied: regex in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2024.4.16)
2024-05-09 11:16:59,158 > Requirement already satisfied: Flask-Limiter<4,>=3.5.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.6.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: semantic-version<3,>=2.10.0 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.10.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: netaddr<0.9,>=0.8 in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.8.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: setuptools in /usr/local/lib/python3.10/site-packages (from OctoPrint->OctoPrint-BambuPrinter==0.0.18) (65.5.1)
2024-05-09 11:16:59,158 > Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/site-packages (from pydantic==1.10.12->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (4.11.0)
2024-05-09 11:16:59,158 > Collecting six>=1.5
2024-05-09 11:16:59,158 > Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
2024-05-09 11:16:59,158 > Requirement already satisfied: argon2-cffi-bindings in /usr/local/lib/python3.10/site-packages (from argon2-cffi>=23.1.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (21.2.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: more-itertools>=5.0.0 in /usr/local/lib/python3.10/site-packages (from class-doc<0.3,>=0.2.6->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (10.2.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: sgmllib3k in /usr/local/lib/python3.10/site-packages (from feedparser<7,>=6.0.11->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.0.0)
2024-05-09 11:16:59,158 > Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.10/site-packages (from flask<2.3,>=2.2.3->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.2.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.10/site-packages (from flask<2.3,>=2.2.3->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.1.3)
2024-05-09 11:16:59,159 > Requirement already satisfied: webassets>=2.0 in /usr/local/lib/python3.10/site-packages (from Flask-Assets<3,>=2.1.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: rich<14,>=12 in /usr/local/lib/python3.10/site-packages (from Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (13.7.1)
2024-05-09 11:16:59,159 > Requirement already satisfied: ordered-set<5,>4 in /usr/local/lib/python3.10/site-packages (from Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (4.1.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: limits>=2.8 in /usr/local/lib/python3.10/site-packages (from Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.11.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests<3,>=2.31.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.7)
2024-05-09 11:16:59,159 > Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests<3,>=2.31.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.2.1)
2024-05-09 11:16:59,159 > Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests<3,>=2.31.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2024.2.2)
2024-05-09 11:16:59,159 > Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/site-packages (from requests<3,>=2.31.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.3.2)
2024-05-09 11:16:59,159 > Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/site-packages (from werkzeug<2.3,>=2.2.3->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.1.5)
2024-05-09 11:16:59,159 > Requirement already satisfied: async-timeout>=3.0.0 in /usr/local/lib/python3.10/site-packages (from zeroconf~=0.127->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (4.0.3)
2024-05-09 11:16:59,159 > Requirement already satisfied: ifaddr>=0.1.7 in /usr/local/lib/python3.10/site-packages (from zeroconf~=0.127->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.2.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: importlib-resources>=1.3 in /usr/local/lib/python3.10/site-packages (from limits>=2.8->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (6.4.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: packaging<25,>=21 in /usr/local/lib/python3.10/site-packages (from limits>=2.8->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (24.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: deprecated>=1.2 in /usr/local/lib/python3.10/site-packages (from limits>=2.8->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.2.14)
2024-05-09 11:16:59,159 > Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/site-packages (from rich<14,>=12->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.17.2)
2024-05-09 11:16:59,159 > Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/site-packages (from rich<14,>=12->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (3.0.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: cffi>=1.0.1 in /usr/local/lib/python3.10/site-packages (from argon2-cffi-bindings->argon2-cffi>=23.1.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (1.16.0)
2024-05-09 11:16:59,159 > Requirement already satisfied: pycparser in /usr/local/lib/python3.10/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi>=23.1.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (2.22)
2024-05-09 11:16:59,159 > Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich<14,>=12->Flask-Limiter<4,>=3.5.0->OctoPrint->OctoPrint-BambuPrinter==0.0.18) (0.1.2)
2024-05-09 11:16:59,159 > Building wheels for collected packages: OctoPrint-BambuPrinter, paho-mqtt
2024-05-09 11:16:59,159 > Building wheel for OctoPrint-BambuPrinter (setup.py): started
2024-05-09 11:17:00,395 > Building wheel for OctoPrint-BambuPrinter (setup.py): finished with status 'done'
2024-05-09 11:17:00,395 > Created wheel for OctoPrint-BambuPrinter: filename=OctoPrint_BambuPrinter-0.0.18-py2.py3-none-any.whl size=18496 sha256=7bf6712a8aa5981cb8e4b9952d9a85677b5a4d07c93db966fc7f5fc17e0487a4
2024-05-09 11:17:00,395 > Stored in directory: /tmp/pip-ephem-wheel-cache-8w6q_vn0/wheels/5b/78/4d/4be6f51abf917047386f0f236b6f2307dd61a62f9738da7072
2024-05-09 11:17:00,395 > Building wheel for paho-mqtt (setup.py): started
2024-05-09 11:17:00,395 > Building wheel for paho-mqtt (setup.py): finished with status 'done'
2024-05-09 11:17:00,395 > Created wheel for paho-mqtt: filename=paho_mqtt-1.6.1-py3-none-any.whl size=62119 sha256=709ff0cf8607da36ac8e384ff8f16332d05238a9950f06bb5ffe81164338e22f
2024-05-09 11:17:00,395 > Stored in directory: /tmp/pip-ephem-wheel-cache-8w6q_vn0/wheels/8b/bb/0c/79444d1dee20324d442856979b5b519b48828b0bd3d05df84a
2024-05-09 11:17:00,395 > Successfully built OctoPrint-BambuPrinter paho-mqtt
2024-05-09 11:17:00,396 > Installing collected packages: paho-mqtt, six, pybambu, python-dateutil, OctoPrint-BambuPrinter
2024-05-09 11:17:00,396 > Successfully installed OctoPrint-BambuPrinter-0.0.18 paho-mqtt-1.6.1 pybambu-1.0.1 python-dateutil-2.9.0.post0 six-1.16.0
2024-05-09 11:17:00,396 ! WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

View File

@ -0,0 +1,2 @@
2024-05-09 16:39:11,261 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log
2024-05-09 16:57:55,435 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log

View File

@ -0,0 +1 @@
2024-05-09 11:47:18,034 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log

View File

@ -0,0 +1 @@
2024-05-09 11:53:18,077 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log

View File

@ -0,0 +1 @@
2024-05-09 13:11:00,883 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 1
defaultExtrusionLength: 5
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _default
model: Generic RepRap Printer
name: DefaultHaha
volume:
custom_box: false
depth: 200.0
formFactor: rectangular
height: 200.0
origin: lowerleft
width: 200.0

View File

@ -0,0 +1,13 @@
_version: 2
shxadmiral:
active: true
apikey: null
groups:
- admins
- users
password: $argon2id$v=19$m=65536,t=3,p=4$611LaU1pzbl3DqHU+v/fuw$szxfnw6XMqlHFiXhyvQxnPxWgOmjbfJgXFvCnTQFqLg
permissions: []
roles:
- user
- admin
settings: {}

View File

@ -0,0 +1,14 @@
Metadata-Version: 2.1
Name: OctoPrint-BambuPrinter
Version: 0.0.18
Summary: Connects OctoPrint to BambuLabs printers.
Home-page: https://github.com/jneilliii/OctoPrint-BambuPrinter
Author: jneilliii
Author-email: jneilliii+github@gmail.com
License: AGPLv3
Requires-Python: >=3.9,<4
Requires-Dist: OctoPrint
Requires-Dist: paho-mqtt <2
Requires-Dist: python-dateutil
Requires-Dist: pybambu >=1.0.1

View File

@ -0,0 +1,18 @@
OctoPrint_BambuPrinter-0.0.18.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
OctoPrint_BambuPrinter-0.0.18.dist-info/METADATA,sha256=Pi7X3cdF1rrZ7usbwZVKBMQ-3TEniY4ylwKAuFCRCZ4,398
OctoPrint_BambuPrinter-0.0.18.dist-info/RECORD,,
OctoPrint_BambuPrinter-0.0.18.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
OctoPrint_BambuPrinter-0.0.18.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
OctoPrint_BambuPrinter-0.0.18.dist-info/direct_url.json,sha256=tn3ua64onz7qZXTCQYO6ylqPSybGhY3AvXl3yUYzf68,88
OctoPrint_BambuPrinter-0.0.18.dist-info/entry_points.txt,sha256=kI338xEBHUTSpRxu5-sVuOW_FdWXtd_WJyBWAnS4RDU,59
OctoPrint_BambuPrinter-0.0.18.dist-info/top_level.txt,sha256=CkUeNWBH39I6l4aG76mkMoSf4P0aX4pr5EQ2aGTvWt4,24
octoprint_bambu_printer/__init__.py,sha256=BGaxOMvRcQHga3XpfVuN6JgqS1Ym2bSCw0pvJ-tBifU,6940
octoprint_bambu_printer/__pycache__/__init__.cpython-310.pyc,,
octoprint_bambu_printer/__pycache__/virtual.cpython-310.pyc,,
octoprint_bambu_printer/ftpsclient/__init__.py,sha256=Uca7tRGQ6Lh1wUt93XdsD-X0hIOWCzq20cFI4ZF_kbE,38
octoprint_bambu_printer/ftpsclient/__pycache__/__init__.cpython-310.pyc,,
octoprint_bambu_printer/ftpsclient/__pycache__/ftpsclient.cpython-310.pyc,,
octoprint_bambu_printer/ftpsclient/ftpsclient.py,sha256=WP-z7j1q-8FlVdtmlNsfVlQzWnVL0Hjx51zI2I2sM8Q,7749
octoprint_bambu_printer/static/js/bambu_printer.js,sha256=-vIC2e9flWqTiC41ORwg0as2ivPIe_wAUC_9v585_y8,6172
octoprint_bambu_printer/templates/bambu_printer_settings.jinja2,sha256=mXczS0fQuV_wuE53tt74ZaMbCf15zb9guDvtgCuIV0E,5104
octoprint_bambu_printer/virtual.py,sha256=8NR4BUSqj_V-X2SxZIXcg7LWNevtSuWbZQ2RJduva60,39069

View File

@ -0,0 +1,6 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.43.0)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any

View File

@ -0,0 +1 @@
{"archive_info": {}, "url": "file:///tmp/tmpfjd_ciah/OctoPrint-BambuPrinter-master.zip"}

View File

@ -0,0 +1,2 @@
[octoprint.plugin]
bambu_printer = octoprint_bambu_printer

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
import sys
try:
from ._version import version as __version__
except ImportError:
__version__ = 'unknown'
__all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz',
'utils', 'zoneinfo']
def __getattr__(name):
import importlib
if name in __all__:
return importlib.import_module("." + name, __name__)
raise AttributeError(
"module {!r} has not attribute {!r}".format(__name__, name)
)
def __dir__():
# __dir__ should include all the lazy-importable modules as well.
return [x for x in globals() if x not in sys.modules] + __all__

View File

@ -0,0 +1,43 @@
"""
Common code used in multiple modules.
"""
class weekday(object):
__slots__ = ["weekday", "n"]
def __init__(self, weekday, n=None):
self.weekday = weekday
self.n = n
def __call__(self, n):
if n == self.n:
return self
else:
return self.__class__(self.weekday, n)
def __eq__(self, other):
try:
if self.weekday != other.weekday or self.n != other.n:
return False
except AttributeError:
return False
return True
def __hash__(self):
return hash((
self.weekday,
self.n,
))
def __ne__(self, other):
return not (self == other)
def __repr__(self):
s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday]
if not self.n:
return s
else:
return "%s(%+d)" % (s, self.n)
# vim:ts=4:sw=4:et

View File

@ -0,0 +1,4 @@
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '2.9.0.post0'
__version_tuple__ = version_tuple = (2, 9, 0)

View File

@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
"""
This module offers a generic Easter computing method for any given year, using
Western, Orthodox or Julian algorithms.
"""
import datetime
__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
EASTER_JULIAN = 1
EASTER_ORTHODOX = 2
EASTER_WESTERN = 3
def easter(year, method=EASTER_WESTERN):
"""
This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, editor.
This algorithm implements three different Easter
calculation methods:
1. Original calculation in Julian calendar, valid in
dates after 326 AD
2. Original method, with date converted to Gregorian
calendar, valid in years 1583 to 4099
3. Revised method, in Gregorian calendar, valid in
years 1583 to 4099 as well
These methods are represented by the constants:
* ``EASTER_JULIAN = 1``
* ``EASTER_ORTHODOX = 2``
* ``EASTER_WESTERN = 3``
The default method is method 3.
More about the algorithm may be found at:
`GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_
and
`The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_
"""
if not (1 <= method <= 3):
raise ValueError("invalid method")
# g - Golden year - 1
# c - Century
# h - (23 - Epact) mod 30
# i - Number of days from March 21 to Paschal Full Moon
# j - Weekday for PFM (0=Sunday, etc)
# p - Number of days from March 21 to Sunday on or before PFM
# (-6 to 28 methods 1 & 3, to 56 for method 2)
# e - Extra days to add for method 2 (converting Julian
# date to Gregorian date)
y = year
g = y % 19
e = 0
if method < 3:
# Old method
i = (19*g + 15) % 30
j = (y + y//4 + i) % 7
if method == 2:
# Extra dates to convert Julian to Gregorian date
e = 10
if y > 1600:
e = e + y//100 - 16 - (y//100 - 16)//4
else:
# New method
c = y//100
h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 30
i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11))
j = (y + y//4 + i + 2 - c + c//4) % 7
# p can be from -6 to 56 corresponding to dates 22 March to 23 May
# (later dates apply to method 2, although 23 May never actually occurs)
p = i - j + e
d = 1 + (p + 27 + (p + 6)//40) % 31
m = 3 + (p + 26)//30
return datetime.date(int(y), int(m), int(d))

View File

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
from ._parser import parse, parser, parserinfo, ParserError
from ._parser import DEFAULTPARSER, DEFAULTTZPARSER
from ._parser import UnknownTimezoneWarning
from ._parser import __doc__
from .isoparser import isoparser, isoparse
__all__ = ['parse', 'parser', 'parserinfo',
'isoparse', 'isoparser',
'ParserError',
'UnknownTimezoneWarning']
###
# Deprecate portions of the private interface so that downstream code that
# is improperly relying on it is given *some* notice.
def __deprecated_private_func(f):
from functools import wraps
import warnings
msg = ('{name} is a private function and may break without warning, '
'it will be moved and or renamed in future versions.')
msg = msg.format(name=f.__name__)
@wraps(f)
def deprecated_func(*args, **kwargs):
warnings.warn(msg, DeprecationWarning)
return f(*args, **kwargs)
return deprecated_func
def __deprecate_private_class(c):
import warnings
msg = ('{name} is a private class and may break without warning, '
'it will be moved and or renamed in future versions.')
msg = msg.format(name=c.__name__)
class private_class(c):
__doc__ = c.__doc__
def __init__(self, *args, **kwargs):
warnings.warn(msg, DeprecationWarning)
super(private_class, self).__init__(*args, **kwargs)
private_class.__name__ = c.__name__
return private_class
from ._parser import _timelex, _resultbase
from ._parser import _tzparser, _parsetz
_timelex = __deprecate_private_class(_timelex)
_tzparser = __deprecate_private_class(_tzparser)
_resultbase = __deprecate_private_class(_resultbase)
_parsetz = __deprecated_private_func(_parsetz)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,416 @@
# -*- coding: utf-8 -*-
"""
This module offers a parser for ISO-8601 strings
It is intended to support all valid date, time and datetime formats per the
ISO-8601 specification.
..versionadded:: 2.7.0
"""
from datetime import datetime, timedelta, time, date
import calendar
from dateutil import tz
from functools import wraps
import re
import six
__all__ = ["isoparse", "isoparser"]
def _takes_ascii(f):
@wraps(f)
def func(self, str_in, *args, **kwargs):
# If it's a stream, read the whole thing
str_in = getattr(str_in, 'read', lambda: str_in)()
# If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII
if isinstance(str_in, six.text_type):
# ASCII is the same in UTF-8
try:
str_in = str_in.encode('ascii')
except UnicodeEncodeError as e:
msg = 'ISO-8601 strings should contain only ASCII characters'
six.raise_from(ValueError(msg), e)
return f(self, str_in, *args, **kwargs)
return func
class isoparser(object):
def __init__(self, sep=None):
"""
:param sep:
A single character that separates date and time portions. If
``None``, the parser will accept any single character.
For strict ISO-8601 adherence, pass ``'T'``.
"""
if sep is not None:
if (len(sep) != 1 or ord(sep) >= 128 or sep in '0123456789'):
raise ValueError('Separator must be a single, non-numeric ' +
'ASCII character')
sep = sep.encode('ascii')
self._sep = sep
@_takes_ascii
def isoparse(self, dt_str):
"""
Parse an ISO-8601 datetime string into a :class:`datetime.datetime`.
An ISO-8601 datetime string consists of a date portion, followed
optionally by a time portion - the date and time portions are separated
by a single character separator, which is ``T`` in the official
standard. Incomplete date formats (such as ``YYYY-MM``) may *not* be
combined with a time portion.
Supported date formats are:
Common:
- ``YYYY``
- ``YYYY-MM``
- ``YYYY-MM-DD`` or ``YYYYMMDD``
Uncommon:
- ``YYYY-Www`` or ``YYYYWww`` - ISO week (day defaults to 0)
- ``YYYY-Www-D`` or ``YYYYWwwD`` - ISO week and day
The ISO week and day numbering follows the same logic as
:func:`datetime.date.isocalendar`.
Supported time formats are:
- ``hh``
- ``hh:mm`` or ``hhmm``
- ``hh:mm:ss`` or ``hhmmss``
- ``hh:mm:ss.ssssss`` (Up to 6 sub-second digits)
Midnight is a special case for `hh`, as the standard supports both
00:00 and 24:00 as a representation. The decimal separator can be
either a dot or a comma.
.. caution::
Support for fractional components other than seconds is part of the
ISO-8601 standard, but is not currently implemented in this parser.
Supported time zone offset formats are:
- `Z` (UTC)
- `±HH:MM`
- `±HHMM`
- `±HH`
Offsets will be represented as :class:`dateutil.tz.tzoffset` objects,
with the exception of UTC, which will be represented as
:class:`dateutil.tz.tzutc`. Time zone offsets equivalent to UTC (such
as `+00:00`) will also be represented as :class:`dateutil.tz.tzutc`.
:param dt_str:
A string or stream containing only an ISO-8601 datetime string
:return:
Returns a :class:`datetime.datetime` representing the string.
Unspecified components default to their lowest value.
.. warning::
As of version 2.7.0, the strictness of the parser should not be
considered a stable part of the contract. Any valid ISO-8601 string
that parses correctly with the default settings will continue to
parse correctly in future versions, but invalid strings that
currently fail (e.g. ``2017-01-01T00:00+00:00:00``) are not
guaranteed to continue failing in future versions if they encode
a valid date.
.. versionadded:: 2.7.0
"""
components, pos = self._parse_isodate(dt_str)
if len(dt_str) > pos:
if self._sep is None or dt_str[pos:pos + 1] == self._sep:
components += self._parse_isotime(dt_str[pos + 1:])
else:
raise ValueError('String contains unknown ISO components')
if len(components) > 3 and components[3] == 24:
components[3] = 0
return datetime(*components) + timedelta(days=1)
return datetime(*components)
@_takes_ascii
def parse_isodate(self, datestr):
"""
Parse the date portion of an ISO string.
:param datestr:
The string portion of an ISO string, without a separator
:return:
Returns a :class:`datetime.date` object
"""
components, pos = self._parse_isodate(datestr)
if pos < len(datestr):
raise ValueError('String contains unknown ISO ' +
'components: {!r}'.format(datestr.decode('ascii')))
return date(*components)
@_takes_ascii
def parse_isotime(self, timestr):
"""
Parse the time portion of an ISO string.
:param timestr:
The time portion of an ISO string, without a separator
:return:
Returns a :class:`datetime.time` object
"""
components = self._parse_isotime(timestr)
if components[0] == 24:
components[0] = 0
return time(*components)
@_takes_ascii
def parse_tzstr(self, tzstr, zero_as_utc=True):
"""
Parse a valid ISO time zone string.
See :func:`isoparser.isoparse` for details on supported formats.
:param tzstr:
A string representing an ISO time zone offset
:param zero_as_utc:
Whether to return :class:`dateutil.tz.tzutc` for zero-offset zones
:return:
Returns :class:`dateutil.tz.tzoffset` for offsets and
:class:`dateutil.tz.tzutc` for ``Z`` and (if ``zero_as_utc`` is
specified) offsets equivalent to UTC.
"""
return self._parse_tzstr(tzstr, zero_as_utc=zero_as_utc)
# Constants
_DATE_SEP = b'-'
_TIME_SEP = b':'
_FRACTION_REGEX = re.compile(b'[\\.,]([0-9]+)')
def _parse_isodate(self, dt_str):
try:
return self._parse_isodate_common(dt_str)
except ValueError:
return self._parse_isodate_uncommon(dt_str)
def _parse_isodate_common(self, dt_str):
len_str = len(dt_str)
components = [1, 1, 1]
if len_str < 4:
raise ValueError('ISO string too short')
# Year
components[0] = int(dt_str[0:4])
pos = 4
if pos >= len_str:
return components, pos
has_sep = dt_str[pos:pos + 1] == self._DATE_SEP
if has_sep:
pos += 1
# Month
if len_str - pos < 2:
raise ValueError('Invalid common month')
components[1] = int(dt_str[pos:pos + 2])
pos += 2
if pos >= len_str:
if has_sep:
return components, pos
else:
raise ValueError('Invalid ISO format')
if has_sep:
if dt_str[pos:pos + 1] != self._DATE_SEP:
raise ValueError('Invalid separator in ISO string')
pos += 1
# Day
if len_str - pos < 2:
raise ValueError('Invalid common day')
components[2] = int(dt_str[pos:pos + 2])
return components, pos + 2
def _parse_isodate_uncommon(self, dt_str):
if len(dt_str) < 4:
raise ValueError('ISO string too short')
# All ISO formats start with the year
year = int(dt_str[0:4])
has_sep = dt_str[4:5] == self._DATE_SEP
pos = 4 + has_sep # Skip '-' if it's there
if dt_str[pos:pos + 1] == b'W':
# YYYY-?Www-?D?
pos += 1
weekno = int(dt_str[pos:pos + 2])
pos += 2
dayno = 1
if len(dt_str) > pos:
if (dt_str[pos:pos + 1] == self._DATE_SEP) != has_sep:
raise ValueError('Inconsistent use of dash separator')
pos += has_sep
dayno = int(dt_str[pos:pos + 1])
pos += 1
base_date = self._calculate_weekdate(year, weekno, dayno)
else:
# YYYYDDD or YYYY-DDD
if len(dt_str) - pos < 3:
raise ValueError('Invalid ordinal day')
ordinal_day = int(dt_str[pos:pos + 3])
pos += 3
if ordinal_day < 1 or ordinal_day > (365 + calendar.isleap(year)):
raise ValueError('Invalid ordinal day' +
' {} for year {}'.format(ordinal_day, year))
base_date = date(year, 1, 1) + timedelta(days=ordinal_day - 1)
components = [base_date.year, base_date.month, base_date.day]
return components, pos
def _calculate_weekdate(self, year, week, day):
"""
Calculate the day of corresponding to the ISO year-week-day calendar.
This function is effectively the inverse of
:func:`datetime.date.isocalendar`.
:param year:
The year in the ISO calendar
:param week:
The week in the ISO calendar - range is [1, 53]
:param day:
The day in the ISO calendar - range is [1 (MON), 7 (SUN)]
:return:
Returns a :class:`datetime.date`
"""
if not 0 < week < 54:
raise ValueError('Invalid week: {}'.format(week))
if not 0 < day < 8: # Range is 1-7
raise ValueError('Invalid weekday: {}'.format(day))
# Get week 1 for the specific year:
jan_4 = date(year, 1, 4) # Week 1 always has January 4th in it
week_1 = jan_4 - timedelta(days=jan_4.isocalendar()[2] - 1)
# Now add the specific number of weeks and days to get what we want
week_offset = (week - 1) * 7 + (day - 1)
return week_1 + timedelta(days=week_offset)
def _parse_isotime(self, timestr):
len_str = len(timestr)
components = [0, 0, 0, 0, None]
pos = 0
comp = -1
if len_str < 2:
raise ValueError('ISO time too short')
has_sep = False
while pos < len_str and comp < 5:
comp += 1
if timestr[pos:pos + 1] in b'-+Zz':
# Detect time zone boundary
components[-1] = self._parse_tzstr(timestr[pos:])
pos = len_str
break
if comp == 1 and timestr[pos:pos+1] == self._TIME_SEP:
has_sep = True
pos += 1
elif comp == 2 and has_sep:
if timestr[pos:pos+1] != self._TIME_SEP:
raise ValueError('Inconsistent use of colon separator')
pos += 1
if comp < 3:
# Hour, minute, second
components[comp] = int(timestr[pos:pos + 2])
pos += 2
if comp == 3:
# Fraction of a second
frac = self._FRACTION_REGEX.match(timestr[pos:])
if not frac:
continue
us_str = frac.group(1)[:6] # Truncate to microseconds
components[comp] = int(us_str) * 10**(6 - len(us_str))
pos += len(frac.group())
if pos < len_str:
raise ValueError('Unused components in ISO string')
if components[0] == 24:
# Standard supports 00:00 and 24:00 as representations of midnight
if any(component != 0 for component in components[1:4]):
raise ValueError('Hour may only be 24 at 24:00:00.000')
return components
def _parse_tzstr(self, tzstr, zero_as_utc=True):
if tzstr == b'Z' or tzstr == b'z':
return tz.UTC
if len(tzstr) not in {3, 5, 6}:
raise ValueError('Time zone offset must be 1, 3, 5 or 6 characters')
if tzstr[0:1] == b'-':
mult = -1
elif tzstr[0:1] == b'+':
mult = 1
else:
raise ValueError('Time zone offset requires sign')
hours = int(tzstr[1:3])
if len(tzstr) == 3:
minutes = 0
else:
minutes = int(tzstr[(4 if tzstr[3:4] == self._TIME_SEP else 3):])
if zero_as_utc and hours == 0 and minutes == 0:
return tz.UTC
else:
if minutes > 59:
raise ValueError('Invalid minutes in time zone offset')
if hours > 23:
raise ValueError('Invalid hours in time zone offset')
return tz.tzoffset(None, mult * (hours * 60 + minutes) * 60)
DEFAULT_ISOPARSER = isoparser()
isoparse = DEFAULT_ISOPARSER.isoparse

View File

@ -0,0 +1,599 @@
# -*- coding: utf-8 -*-
import datetime
import calendar
import operator
from math import copysign
from six import integer_types
from warnings import warn
from ._common import weekday
MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7))
__all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
class relativedelta(object):
"""
The relativedelta type is designed to be applied to an existing datetime and
can replace specific components of that datetime, or represents an interval
of time.
It is based on the specification of the excellent work done by M.-A. Lemburg
in his
`mx.DateTime <https://www.egenix.com/products/python/mxBase/mxDateTime/>`_ extension.
However, notice that this type does *NOT* implement the same algorithm as
his work. Do *NOT* expect it to behave like mx.DateTime's counterpart.
There are two different ways to build a relativedelta instance. The
first one is passing it two date/datetime classes::
relativedelta(datetime1, datetime2)
The second one is passing it any number of the following keyword arguments::
relativedelta(arg1=x,arg2=y,arg3=z...)
year, month, day, hour, minute, second, microsecond:
Absolute information (argument is singular); adding or subtracting a
relativedelta with absolute information does not perform an arithmetic
operation, but rather REPLACES the corresponding value in the
original datetime with the value(s) in relativedelta.
years, months, weeks, days, hours, minutes, seconds, microseconds:
Relative information, may be negative (argument is plural); adding
or subtracting a relativedelta with relative information performs
the corresponding arithmetic operation on the original datetime value
with the information in the relativedelta.
weekday:
One of the weekday instances (MO, TU, etc) available in the
relativedelta module. These instances may receive a parameter N,
specifying the Nth weekday, which could be positive or negative
(like MO(+1) or MO(-2)). Not specifying it is the same as specifying
+1. You can also use an integer, where 0=MO. This argument is always
relative e.g. if the calculated date is already Monday, using MO(1)
or MO(-1) won't change the day. To effectively make it absolute, use
it in combination with the day argument (e.g. day=1, MO(1) for first
Monday of the month).
leapdays:
Will add given days to the date found, if year is a leap
year, and the date found is post 28 of february.
yearday, nlyearday:
Set the yearday or the non-leap year day (jump leap days).
These are converted to day/month/leapdays information.
There are relative and absolute forms of the keyword
arguments. The plural is relative, and the singular is
absolute. For each argument in the order below, the absolute form
is applied first (by setting each attribute to that value) and
then the relative form (by adding the value to the attribute).
The order of attributes considered when this relativedelta is
added to a datetime is:
1. Year
2. Month
3. Day
4. Hours
5. Minutes
6. Seconds
7. Microseconds
Finally, weekday is applied, using the rule described above.
For example
>>> from datetime import datetime
>>> from dateutil.relativedelta import relativedelta, MO
>>> dt = datetime(2018, 4, 9, 13, 37, 0)
>>> delta = relativedelta(hours=25, day=1, weekday=MO(1))
>>> dt + delta
datetime.datetime(2018, 4, 2, 14, 37)
First, the day is set to 1 (the first of the month), then 25 hours
are added, to get to the 2nd day and 14th hour, finally the
weekday is applied, but since the 2nd is already a Monday there is
no effect.
"""
def __init__(self, dt1=None, dt2=None,
years=0, months=0, days=0, leapdays=0, weeks=0,
hours=0, minutes=0, seconds=0, microseconds=0,
year=None, month=None, day=None, weekday=None,
yearday=None, nlyearday=None,
hour=None, minute=None, second=None, microsecond=None):
if dt1 and dt2:
# datetime is a subclass of date. So both must be date
if not (isinstance(dt1, datetime.date) and
isinstance(dt2, datetime.date)):
raise TypeError("relativedelta only diffs datetime/date")
# We allow two dates, or two datetimes, so we coerce them to be
# of the same type
if (isinstance(dt1, datetime.datetime) !=
isinstance(dt2, datetime.datetime)):
if not isinstance(dt1, datetime.datetime):
dt1 = datetime.datetime.fromordinal(dt1.toordinal())
elif not isinstance(dt2, datetime.datetime):
dt2 = datetime.datetime.fromordinal(dt2.toordinal())
self.years = 0
self.months = 0
self.days = 0
self.leapdays = 0
self.hours = 0
self.minutes = 0
self.seconds = 0
self.microseconds = 0
self.year = None
self.month = None
self.day = None
self.weekday = None
self.hour = None
self.minute = None
self.second = None
self.microsecond = None
self._has_time = 0
# Get year / month delta between the two
months = (dt1.year - dt2.year) * 12 + (dt1.month - dt2.month)
self._set_months(months)
# Remove the year/month delta so the timedelta is just well-defined
# time units (seconds, days and microseconds)
dtm = self.__radd__(dt2)
# If we've overshot our target, make an adjustment
if dt1 < dt2:
compare = operator.gt
increment = 1
else:
compare = operator.lt
increment = -1
while compare(dt1, dtm):
months += increment
self._set_months(months)
dtm = self.__radd__(dt2)
# Get the timedelta between the "months-adjusted" date and dt1
delta = dt1 - dtm
self.seconds = delta.seconds + delta.days * 86400
self.microseconds = delta.microseconds
else:
# Check for non-integer values in integer-only quantities
if any(x is not None and x != int(x) for x in (years, months)):
raise ValueError("Non-integer years and months are "
"ambiguous and not currently supported.")
# Relative information
self.years = int(years)
self.months = int(months)
self.days = days + weeks * 7
self.leapdays = leapdays
self.hours = hours
self.minutes = minutes
self.seconds = seconds
self.microseconds = microseconds
# Absolute information
self.year = year
self.month = month
self.day = day
self.hour = hour
self.minute = minute
self.second = second
self.microsecond = microsecond
if any(x is not None and int(x) != x
for x in (year, month, day, hour,
minute, second, microsecond)):
# For now we'll deprecate floats - later it'll be an error.
warn("Non-integer value passed as absolute information. " +
"This is not a well-defined condition and will raise " +
"errors in future versions.", DeprecationWarning)
if isinstance(weekday, integer_types):
self.weekday = weekdays[weekday]
else:
self.weekday = weekday
yday = 0
if nlyearday:
yday = nlyearday
elif yearday:
yday = yearday
if yearday > 59:
self.leapdays = -1
if yday:
ydayidx = [31, 59, 90, 120, 151, 181, 212,
243, 273, 304, 334, 366]
for idx, ydays in enumerate(ydayidx):
if yday <= ydays:
self.month = idx+1
if idx == 0:
self.day = yday
else:
self.day = yday-ydayidx[idx-1]
break
else:
raise ValueError("invalid year day (%d)" % yday)
self._fix()
def _fix(self):
if abs(self.microseconds) > 999999:
s = _sign(self.microseconds)
div, mod = divmod(self.microseconds * s, 1000000)
self.microseconds = mod * s
self.seconds += div * s
if abs(self.seconds) > 59:
s = _sign(self.seconds)
div, mod = divmod(self.seconds * s, 60)
self.seconds = mod * s
self.minutes += div * s
if abs(self.minutes) > 59:
s = _sign(self.minutes)
div, mod = divmod(self.minutes * s, 60)
self.minutes = mod * s
self.hours += div * s
if abs(self.hours) > 23:
s = _sign(self.hours)
div, mod = divmod(self.hours * s, 24)
self.hours = mod * s
self.days += div * s
if abs(self.months) > 11:
s = _sign(self.months)
div, mod = divmod(self.months * s, 12)
self.months = mod * s
self.years += div * s
if (self.hours or self.minutes or self.seconds or self.microseconds
or self.hour is not None or self.minute is not None or
self.second is not None or self.microsecond is not None):
self._has_time = 1
else:
self._has_time = 0
@property
def weeks(self):
return int(self.days / 7.0)
@weeks.setter
def weeks(self, value):
self.days = self.days - (self.weeks * 7) + value * 7
def _set_months(self, months):
self.months = months
if abs(self.months) > 11:
s = _sign(self.months)
div, mod = divmod(self.months * s, 12)
self.months = mod * s
self.years = div * s
else:
self.years = 0
def normalized(self):
"""
Return a version of this object represented entirely using integer
values for the relative attributes.
>>> relativedelta(days=1.5, hours=2).normalized()
relativedelta(days=+1, hours=+14)
:return:
Returns a :class:`dateutil.relativedelta.relativedelta` object.
"""
# Cascade remainders down (rounding each to roughly nearest microsecond)
days = int(self.days)
hours_f = round(self.hours + 24 * (self.days - days), 11)
hours = int(hours_f)
minutes_f = round(self.minutes + 60 * (hours_f - hours), 10)
minutes = int(minutes_f)
seconds_f = round(self.seconds + 60 * (minutes_f - minutes), 8)
seconds = int(seconds_f)
microseconds = round(self.microseconds + 1e6 * (seconds_f - seconds))
# Constructor carries overflow back up with call to _fix()
return self.__class__(years=self.years, months=self.months,
days=days, hours=hours, minutes=minutes,
seconds=seconds, microseconds=microseconds,
leapdays=self.leapdays, year=self.year,
month=self.month, day=self.day,
weekday=self.weekday, hour=self.hour,
minute=self.minute, second=self.second,
microsecond=self.microsecond)
def __add__(self, other):
if isinstance(other, relativedelta):
return self.__class__(years=other.years + self.years,
months=other.months + self.months,
days=other.days + self.days,
hours=other.hours + self.hours,
minutes=other.minutes + self.minutes,
seconds=other.seconds + self.seconds,
microseconds=(other.microseconds +
self.microseconds),
leapdays=other.leapdays or self.leapdays,
year=(other.year if other.year is not None
else self.year),
month=(other.month if other.month is not None
else self.month),
day=(other.day if other.day is not None
else self.day),
weekday=(other.weekday if other.weekday is not None
else self.weekday),
hour=(other.hour if other.hour is not None
else self.hour),
minute=(other.minute if other.minute is not None
else self.minute),
second=(other.second if other.second is not None
else self.second),
microsecond=(other.microsecond if other.microsecond
is not None else
self.microsecond))
if isinstance(other, datetime.timedelta):
return self.__class__(years=self.years,
months=self.months,
days=self.days + other.days,
hours=self.hours,
minutes=self.minutes,
seconds=self.seconds + other.seconds,
microseconds=self.microseconds + other.microseconds,
leapdays=self.leapdays,
year=self.year,
month=self.month,
day=self.day,
weekday=self.weekday,
hour=self.hour,
minute=self.minute,
second=self.second,
microsecond=self.microsecond)
if not isinstance(other, datetime.date):
return NotImplemented
elif self._has_time and not isinstance(other, datetime.datetime):
other = datetime.datetime.fromordinal(other.toordinal())
year = (self.year or other.year)+self.years
month = self.month or other.month
if self.months:
assert 1 <= abs(self.months) <= 12
month += self.months
if month > 12:
year += 1
month -= 12
elif month < 1:
year -= 1
month += 12
day = min(calendar.monthrange(year, month)[1],
self.day or other.day)
repl = {"year": year, "month": month, "day": day}
for attr in ["hour", "minute", "second", "microsecond"]:
value = getattr(self, attr)
if value is not None:
repl[attr] = value
days = self.days
if self.leapdays and month > 2 and calendar.isleap(year):
days += self.leapdays
ret = (other.replace(**repl)
+ datetime.timedelta(days=days,
hours=self.hours,
minutes=self.minutes,
seconds=self.seconds,
microseconds=self.microseconds))
if self.weekday:
weekday, nth = self.weekday.weekday, self.weekday.n or 1
jumpdays = (abs(nth) - 1) * 7
if nth > 0:
jumpdays += (7 - ret.weekday() + weekday) % 7
else:
jumpdays += (ret.weekday() - weekday) % 7
jumpdays *= -1
ret += datetime.timedelta(days=jumpdays)
return ret
def __radd__(self, other):
return self.__add__(other)
def __rsub__(self, other):
return self.__neg__().__radd__(other)
def __sub__(self, other):
if not isinstance(other, relativedelta):
return NotImplemented # In case the other object defines __rsub__
return self.__class__(years=self.years - other.years,
months=self.months - other.months,
days=self.days - other.days,
hours=self.hours - other.hours,
minutes=self.minutes - other.minutes,
seconds=self.seconds - other.seconds,
microseconds=self.microseconds - other.microseconds,
leapdays=self.leapdays or other.leapdays,
year=(self.year if self.year is not None
else other.year),
month=(self.month if self.month is not None else
other.month),
day=(self.day if self.day is not None else
other.day),
weekday=(self.weekday if self.weekday is not None else
other.weekday),
hour=(self.hour if self.hour is not None else
other.hour),
minute=(self.minute if self.minute is not None else
other.minute),
second=(self.second if self.second is not None else
other.second),
microsecond=(self.microsecond if self.microsecond
is not None else
other.microsecond))
def __abs__(self):
return self.__class__(years=abs(self.years),
months=abs(self.months),
days=abs(self.days),
hours=abs(self.hours),
minutes=abs(self.minutes),
seconds=abs(self.seconds),
microseconds=abs(self.microseconds),
leapdays=self.leapdays,
year=self.year,
month=self.month,
day=self.day,
weekday=self.weekday,
hour=self.hour,
minute=self.minute,
second=self.second,
microsecond=self.microsecond)
def __neg__(self):
return self.__class__(years=-self.years,
months=-self.months,
days=-self.days,
hours=-self.hours,
minutes=-self.minutes,
seconds=-self.seconds,
microseconds=-self.microseconds,
leapdays=self.leapdays,
year=self.year,
month=self.month,
day=self.day,
weekday=self.weekday,
hour=self.hour,
minute=self.minute,
second=self.second,
microsecond=self.microsecond)
def __bool__(self):
return not (not self.years and
not self.months and
not self.days and
not self.hours and
not self.minutes and
not self.seconds and
not self.microseconds and
not self.leapdays and
self.year is None and
self.month is None and
self.day is None and
self.weekday is None and
self.hour is None and
self.minute is None and
self.second is None and
self.microsecond is None)
# Compatibility with Python 2.x
__nonzero__ = __bool__
def __mul__(self, other):
try:
f = float(other)
except TypeError:
return NotImplemented
return self.__class__(years=int(self.years * f),
months=int(self.months * f),
days=int(self.days * f),
hours=int(self.hours * f),
minutes=int(self.minutes * f),
seconds=int(self.seconds * f),
microseconds=int(self.microseconds * f),
leapdays=self.leapdays,
year=self.year,
month=self.month,
day=self.day,
weekday=self.weekday,
hour=self.hour,
minute=self.minute,
second=self.second,
microsecond=self.microsecond)
__rmul__ = __mul__
def __eq__(self, other):
if not isinstance(other, relativedelta):
return NotImplemented
if self.weekday or other.weekday:
if not self.weekday or not other.weekday:
return False
if self.weekday.weekday != other.weekday.weekday:
return False
n1, n2 = self.weekday.n, other.weekday.n
if n1 != n2 and not ((not n1 or n1 == 1) and (not n2 or n2 == 1)):
return False
return (self.years == other.years and
self.months == other.months and
self.days == other.days and
self.hours == other.hours and
self.minutes == other.minutes and
self.seconds == other.seconds and
self.microseconds == other.microseconds and
self.leapdays == other.leapdays and
self.year == other.year and
self.month == other.month and
self.day == other.day and
self.hour == other.hour and
self.minute == other.minute and
self.second == other.second and
self.microsecond == other.microsecond)
def __hash__(self):
return hash((
self.weekday,
self.years,
self.months,
self.days,
self.hours,
self.minutes,
self.seconds,
self.microseconds,
self.leapdays,
self.year,
self.month,
self.day,
self.hour,
self.minute,
self.second,
self.microsecond,
))
def __ne__(self, other):
return not self.__eq__(other)
def __div__(self, other):
try:
reciprocal = 1 / float(other)
except TypeError:
return NotImplemented
return self.__mul__(reciprocal)
__truediv__ = __div__
def __repr__(self):
l = []
for attr in ["years", "months", "days", "leapdays",
"hours", "minutes", "seconds", "microseconds"]:
value = getattr(self, attr)
if value:
l.append("{attr}={value:+g}".format(attr=attr, value=value))
for attr in ["year", "month", "day", "weekday",
"hour", "minute", "second", "microsecond"]:
value = getattr(self, attr)
if value is not None:
l.append("{attr}={value}".format(attr=attr, value=repr(value)))
return "{classname}({attrs})".format(classname=self.__class__.__name__,
attrs=", ".join(l))
def _sign(x):
return int(copysign(1, x))
# vim:ts=4:sw=4:et

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from .tz import *
from .tz import __doc__
__all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
"tzstr", "tzical", "tzwin", "tzwinlocal", "gettz",
"enfold", "datetime_ambiguous", "datetime_exists",
"resolve_imaginary", "UTC", "DeprecatedTzFormatWarning"]
class DeprecatedTzFormatWarning(Warning):
"""Warning raised when time zones are parsed from deprecated formats."""

View File

@ -0,0 +1,419 @@
from six import PY2
from functools import wraps
from datetime import datetime, timedelta, tzinfo
ZERO = timedelta(0)
__all__ = ['tzname_in_python2', 'enfold']
def tzname_in_python2(namefunc):
"""Change unicode output into bytestrings in Python 2
tzname() API changed in Python 3. It used to return bytes, but was changed
to unicode strings
"""
if PY2:
@wraps(namefunc)
def adjust_encoding(*args, **kwargs):
name = namefunc(*args, **kwargs)
if name is not None:
name = name.encode()
return name
return adjust_encoding
else:
return namefunc
# The following is adapted from Alexander Belopolsky's tz library
# https://github.com/abalkin/tz
if hasattr(datetime, 'fold'):
# This is the pre-python 3.6 fold situation
def enfold(dt, fold=1):
"""
Provides a unified interface for assigning the ``fold`` attribute to
datetimes both before and after the implementation of PEP-495.
:param fold:
The value for the ``fold`` attribute in the returned datetime. This
should be either 0 or 1.
:return:
Returns an object for which ``getattr(dt, 'fold', 0)`` returns
``fold`` for all versions of Python. In versions prior to
Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
subclass of :py:class:`datetime.datetime` with the ``fold``
attribute added, if ``fold`` is 1.
.. versionadded:: 2.6.0
"""
return dt.replace(fold=fold)
else:
class _DatetimeWithFold(datetime):
"""
This is a class designed to provide a PEP 495-compliant interface for
Python versions before 3.6. It is used only for dates in a fold, so
the ``fold`` attribute is fixed at ``1``.
.. versionadded:: 2.6.0
"""
__slots__ = ()
def replace(self, *args, **kwargs):
"""
Return a datetime with the same attributes, except for those
attributes given new values by whichever keyword arguments are
specified. Note that tzinfo=None can be specified to create a naive
datetime from an aware datetime with no conversion of date and time
data.
This is reimplemented in ``_DatetimeWithFold`` because pypy3 will
return a ``datetime.datetime`` even if ``fold`` is unchanged.
"""
argnames = (
'year', 'month', 'day', 'hour', 'minute', 'second',
'microsecond', 'tzinfo'
)
for arg, argname in zip(args, argnames):
if argname in kwargs:
raise TypeError('Duplicate argument: {}'.format(argname))
kwargs[argname] = arg
for argname in argnames:
if argname not in kwargs:
kwargs[argname] = getattr(self, argname)
dt_class = self.__class__ if kwargs.get('fold', 1) else datetime
return dt_class(**kwargs)
@property
def fold(self):
return 1
def enfold(dt, fold=1):
"""
Provides a unified interface for assigning the ``fold`` attribute to
datetimes both before and after the implementation of PEP-495.
:param fold:
The value for the ``fold`` attribute in the returned datetime. This
should be either 0 or 1.
:return:
Returns an object for which ``getattr(dt, 'fold', 0)`` returns
``fold`` for all versions of Python. In versions prior to
Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
subclass of :py:class:`datetime.datetime` with the ``fold``
attribute added, if ``fold`` is 1.
.. versionadded:: 2.6.0
"""
if getattr(dt, 'fold', 0) == fold:
return dt
args = dt.timetuple()[:6]
args += (dt.microsecond, dt.tzinfo)
if fold:
return _DatetimeWithFold(*args)
else:
return datetime(*args)
def _validate_fromutc_inputs(f):
"""
The CPython version of ``fromutc`` checks that the input is a ``datetime``
object and that ``self`` is attached as its ``tzinfo``.
"""
@wraps(f)
def fromutc(self, dt):
if not isinstance(dt, datetime):
raise TypeError("fromutc() requires a datetime argument")
if dt.tzinfo is not self:
raise ValueError("dt.tzinfo is not self")
return f(self, dt)
return fromutc
class _tzinfo(tzinfo):
"""
Base class for all ``dateutil`` ``tzinfo`` objects.
"""
def is_ambiguous(self, dt):
"""
Whether or not the "wall time" of a given datetime is ambiguous in this
zone.
:param dt:
A :py:class:`datetime.datetime`, naive or time zone aware.
:return:
Returns ``True`` if ambiguous, ``False`` otherwise.
.. versionadded:: 2.6.0
"""
dt = dt.replace(tzinfo=self)
wall_0 = enfold(dt, fold=0)
wall_1 = enfold(dt, fold=1)
same_offset = wall_0.utcoffset() == wall_1.utcoffset()
same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)
return same_dt and not same_offset
def _fold_status(self, dt_utc, dt_wall):
"""
Determine the fold status of a "wall" datetime, given a representation
of the same datetime as a (naive) UTC datetime. This is calculated based
on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
datetimes, and that this offset is the actual number of hours separating
``dt_utc`` and ``dt_wall``.
:param dt_utc:
Representation of the datetime as UTC
:param dt_wall:
Representation of the datetime as "wall time". This parameter must
either have a `fold` attribute or have a fold-naive
:class:`datetime.tzinfo` attached, otherwise the calculation may
fail.
"""
if self.is_ambiguous(dt_wall):
delta_wall = dt_wall - dt_utc
_fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst()))
else:
_fold = 0
return _fold
def _fold(self, dt):
return getattr(dt, 'fold', 0)
def _fromutc(self, dt):
"""
Given a timezone-aware datetime in a given timezone, calculates a
timezone-aware datetime in a new timezone.
Since this is the one time that we *know* we have an unambiguous
datetime object, we take this opportunity to determine whether the
datetime is ambiguous and in a "fold" state (e.g. if it's the first
occurrence, chronologically, of the ambiguous datetime).
:param dt:
A timezone-aware :class:`datetime.datetime` object.
"""
# Re-implement the algorithm from Python's datetime.py
dtoff = dt.utcoffset()
if dtoff is None:
raise ValueError("fromutc() requires a non-None utcoffset() "
"result")
# The original datetime.py code assumes that `dst()` defaults to
# zero during ambiguous times. PEP 495 inverts this presumption, so
# for pre-PEP 495 versions of python, we need to tweak the algorithm.
dtdst = dt.dst()
if dtdst is None:
raise ValueError("fromutc() requires a non-None dst() result")
delta = dtoff - dtdst
dt += delta
# Set fold=1 so we can default to being in the fold for
# ambiguous dates.
dtdst = enfold(dt, fold=1).dst()
if dtdst is None:
raise ValueError("fromutc(): dt.dst gave inconsistent "
"results; cannot convert")
return dt + dtdst
@_validate_fromutc_inputs
def fromutc(self, dt):
"""
Given a timezone-aware datetime in a given timezone, calculates a
timezone-aware datetime in a new timezone.
Since this is the one time that we *know* we have an unambiguous
datetime object, we take this opportunity to determine whether the
datetime is ambiguous and in a "fold" state (e.g. if it's the first
occurrence, chronologically, of the ambiguous datetime).
:param dt:
A timezone-aware :class:`datetime.datetime` object.
"""
dt_wall = self._fromutc(dt)
# Calculate the fold status given the two datetimes.
_fold = self._fold_status(dt, dt_wall)
# Set the default fold value for ambiguous dates
return enfold(dt_wall, fold=_fold)
class tzrangebase(_tzinfo):
"""
This is an abstract base class for time zones represented by an annual
transition into and out of DST. Child classes should implement the following
methods:
* ``__init__(self, *args, **kwargs)``
* ``transitions(self, year)`` - this is expected to return a tuple of
datetimes representing the DST on and off transitions in standard
time.
A fully initialized ``tzrangebase`` subclass should also provide the
following attributes:
* ``hasdst``: Boolean whether or not the zone uses DST.
* ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
representing the respective UTC offsets.
* ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
abbreviations in DST and STD, respectively.
* ``_hasdst``: Whether or not the zone has DST.
.. versionadded:: 2.6.0
"""
def __init__(self):
raise NotImplementedError('tzrangebase is an abstract base class')
def utcoffset(self, dt):
isdst = self._isdst(dt)
if isdst is None:
return None
elif isdst:
return self._dst_offset
else:
return self._std_offset
def dst(self, dt):
isdst = self._isdst(dt)
if isdst is None:
return None
elif isdst:
return self._dst_base_offset
else:
return ZERO
@tzname_in_python2
def tzname(self, dt):
if self._isdst(dt):
return self._dst_abbr
else:
return self._std_abbr
def fromutc(self, dt):
""" Given a datetime in UTC, return local time """
if not isinstance(dt, datetime):
raise TypeError("fromutc() requires a datetime argument")
if dt.tzinfo is not self:
raise ValueError("dt.tzinfo is not self")
# Get transitions - if there are none, fixed offset
transitions = self.transitions(dt.year)
if transitions is None:
return dt + self.utcoffset(dt)
# Get the transition times in UTC
dston, dstoff = transitions
dston -= self._std_offset
dstoff -= self._std_offset
utc_transitions = (dston, dstoff)
dt_utc = dt.replace(tzinfo=None)
isdst = self._naive_isdst(dt_utc, utc_transitions)
if isdst:
dt_wall = dt + self._dst_offset
else:
dt_wall = dt + self._std_offset
_fold = int(not isdst and self.is_ambiguous(dt_wall))
return enfold(dt_wall, fold=_fold)
def is_ambiguous(self, dt):
"""
Whether or not the "wall time" of a given datetime is ambiguous in this
zone.
:param dt:
A :py:class:`datetime.datetime`, naive or time zone aware.
:return:
Returns ``True`` if ambiguous, ``False`` otherwise.
.. versionadded:: 2.6.0
"""
if not self.hasdst:
return False
start, end = self.transitions(dt.year)
dt = dt.replace(tzinfo=None)
return (end <= dt < end + self._dst_base_offset)
def _isdst(self, dt):
if not self.hasdst:
return False
elif dt is None:
return None
transitions = self.transitions(dt.year)
if transitions is None:
return False
dt = dt.replace(tzinfo=None)
isdst = self._naive_isdst(dt, transitions)
# Handle ambiguous dates
if not isdst and self.is_ambiguous(dt):
return not self._fold(dt)
else:
return isdst
def _naive_isdst(self, dt, transitions):
dston, dstoff = transitions
dt = dt.replace(tzinfo=None)
if dston < dstoff:
isdst = dston <= dt < dstoff
else:
isdst = not dstoff <= dt < dston
return isdst
@property
def _dst_base_offset(self):
return self._dst_offset - self._std_offset
__hash__ = None
def __ne__(self, other):
return not (self == other)
def __repr__(self):
return "%s(...)" % self.__class__.__name__
__reduce__ = object.__reduce__

View File

@ -0,0 +1,80 @@
from datetime import timedelta
import weakref
from collections import OrderedDict
from six.moves import _thread
class _TzSingleton(type):
def __init__(cls, *args, **kwargs):
cls.__instance = None
super(_TzSingleton, cls).__init__(*args, **kwargs)
def __call__(cls):
if cls.__instance is None:
cls.__instance = super(_TzSingleton, cls).__call__()
return cls.__instance
class _TzFactory(type):
def instance(cls, *args, **kwargs):
"""Alternate constructor that returns a fresh instance"""
return type.__call__(cls, *args, **kwargs)
class _TzOffsetFactory(_TzFactory):
def __init__(cls, *args, **kwargs):
cls.__instances = weakref.WeakValueDictionary()
cls.__strong_cache = OrderedDict()
cls.__strong_cache_size = 8
cls._cache_lock = _thread.allocate_lock()
def __call__(cls, name, offset):
if isinstance(offset, timedelta):
key = (name, offset.total_seconds())
else:
key = (name, offset)
instance = cls.__instances.get(key, None)
if instance is None:
instance = cls.__instances.setdefault(key,
cls.instance(name, offset))
# This lock may not be necessary in Python 3. See GH issue #901
with cls._cache_lock:
cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance)
# Remove an item if the strong cache is overpopulated
if len(cls.__strong_cache) > cls.__strong_cache_size:
cls.__strong_cache.popitem(last=False)
return instance
class _TzStrFactory(_TzFactory):
def __init__(cls, *args, **kwargs):
cls.__instances = weakref.WeakValueDictionary()
cls.__strong_cache = OrderedDict()
cls.__strong_cache_size = 8
cls.__cache_lock = _thread.allocate_lock()
def __call__(cls, s, posix_offset=False):
key = (s, posix_offset)
instance = cls.__instances.get(key, None)
if instance is None:
instance = cls.__instances.setdefault(key,
cls.instance(s, posix_offset))
# This lock may not be necessary in Python 3. See GH issue #901
with cls.__cache_lock:
cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance)
# Remove an item if the strong cache is overpopulated
if len(cls.__strong_cache) > cls.__strong_cache_size:
cls.__strong_cache.popitem(last=False)
return instance

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,370 @@
# -*- coding: utf-8 -*-
"""
This module provides an interface to the native time zone data on Windows,
including :py:class:`datetime.tzinfo` implementations.
Attempting to import this module on a non-Windows platform will raise an
:py:obj:`ImportError`.
"""
# This code was originally contributed by Jeffrey Harris.
import datetime
import struct
from six.moves import winreg
from six import text_type
try:
import ctypes
from ctypes import wintypes
except ValueError:
# ValueError is raised on non-Windows systems for some horrible reason.
raise ImportError("Running tzwin on non-Windows system")
from ._common import tzrangebase
__all__ = ["tzwin", "tzwinlocal", "tzres"]
ONEWEEK = datetime.timedelta(7)
TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
TZKEYNAME9X = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones"
TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
def _settzkeyname():
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
try:
winreg.OpenKey(handle, TZKEYNAMENT).Close()
TZKEYNAME = TZKEYNAMENT
except WindowsError:
TZKEYNAME = TZKEYNAME9X
handle.Close()
return TZKEYNAME
TZKEYNAME = _settzkeyname()
class tzres(object):
"""
Class for accessing ``tzres.dll``, which contains timezone name related
resources.
.. versionadded:: 2.5.0
"""
p_wchar = ctypes.POINTER(wintypes.WCHAR) # Pointer to a wide char
def __init__(self, tzres_loc='tzres.dll'):
# Load the user32 DLL so we can load strings from tzres
user32 = ctypes.WinDLL('user32')
# Specify the LoadStringW function
user32.LoadStringW.argtypes = (wintypes.HINSTANCE,
wintypes.UINT,
wintypes.LPWSTR,
ctypes.c_int)
self.LoadStringW = user32.LoadStringW
self._tzres = ctypes.WinDLL(tzres_loc)
self.tzres_loc = tzres_loc
def load_name(self, offset):
"""
Load a timezone name from a DLL offset (integer).
>>> from dateutil.tzwin import tzres
>>> tzr = tzres()
>>> print(tzr.load_name(112))
'Eastern Standard Time'
:param offset:
A positive integer value referring to a string from the tzres dll.
.. note::
Offsets found in the registry are generally of the form
``@tzres.dll,-114``. The offset in this case is 114, not -114.
"""
resource = self.p_wchar()
lpBuffer = ctypes.cast(ctypes.byref(resource), wintypes.LPWSTR)
nchar = self.LoadStringW(self._tzres._handle, offset, lpBuffer, 0)
return resource[:nchar]
def name_from_string(self, tzname_str):
"""
Parse strings as returned from the Windows registry into the time zone
name as defined in the registry.
>>> from dateutil.tzwin import tzres
>>> tzr = tzres()
>>> print(tzr.name_from_string('@tzres.dll,-251'))
'Dateline Daylight Time'
>>> print(tzr.name_from_string('Eastern Standard Time'))
'Eastern Standard Time'
:param tzname_str:
A timezone name string as returned from a Windows registry key.
:return:
Returns the localized timezone string from tzres.dll if the string
is of the form `@tzres.dll,-offset`, else returns the input string.
"""
if not tzname_str.startswith('@'):
return tzname_str
name_splt = tzname_str.split(',-')
try:
offset = int(name_splt[1])
except:
raise ValueError("Malformed timezone string.")
return self.load_name(offset)
class tzwinbase(tzrangebase):
"""tzinfo class based on win32's timezones available in the registry."""
def __init__(self):
raise NotImplementedError('tzwinbase is an abstract base class')
def __eq__(self, other):
# Compare on all relevant dimensions, including name.
if not isinstance(other, tzwinbase):
return NotImplemented
return (self._std_offset == other._std_offset and
self._dst_offset == other._dst_offset and
self._stddayofweek == other._stddayofweek and
self._dstdayofweek == other._dstdayofweek and
self._stdweeknumber == other._stdweeknumber and
self._dstweeknumber == other._dstweeknumber and
self._stdhour == other._stdhour and
self._dsthour == other._dsthour and
self._stdminute == other._stdminute and
self._dstminute == other._dstminute and
self._std_abbr == other._std_abbr and
self._dst_abbr == other._dst_abbr)
@staticmethod
def list():
"""Return a list of all time zones known to the system."""
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
with winreg.OpenKey(handle, TZKEYNAME) as tzkey:
result = [winreg.EnumKey(tzkey, i)
for i in range(winreg.QueryInfoKey(tzkey)[0])]
return result
def display(self):
"""
Return the display name of the time zone.
"""
return self._display
def transitions(self, year):
"""
For a given year, get the DST on and off transition times, expressed
always on the standard time side. For zones with no transitions, this
function returns ``None``.
:param year:
The year whose transitions you would like to query.
:return:
Returns a :class:`tuple` of :class:`datetime.datetime` objects,
``(dston, dstoff)`` for zones with an annual DST transition, or
``None`` for fixed offset zones.
"""
if not self.hasdst:
return None
dston = picknthweekday(year, self._dstmonth, self._dstdayofweek,
self._dsthour, self._dstminute,
self._dstweeknumber)
dstoff = picknthweekday(year, self._stdmonth, self._stddayofweek,
self._stdhour, self._stdminute,
self._stdweeknumber)
# Ambiguous dates default to the STD side
dstoff -= self._dst_base_offset
return dston, dstoff
def _get_hasdst(self):
return self._dstmonth != 0
@property
def _dst_base_offset(self):
return self._dst_base_offset_
class tzwin(tzwinbase):
"""
Time zone object created from the zone info in the Windows registry
These are similar to :py:class:`dateutil.tz.tzrange` objects in that
the time zone data is provided in the format of a single offset rule
for either 0 or 2 time zone transitions per year.
:param: name
The name of a Windows time zone key, e.g. "Eastern Standard Time".
The full list of keys can be retrieved with :func:`tzwin.list`.
"""
def __init__(self, name):
self._name = name
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
with winreg.OpenKey(handle, tzkeyname) as tzkey:
keydict = valuestodict(tzkey)
self._std_abbr = keydict["Std"]
self._dst_abbr = keydict["Dlt"]
self._display = keydict["Display"]
# See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
tup = struct.unpack("=3l16h", keydict["TZI"])
stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
dstoffset = stdoffset-tup[2] # + DaylightBias * -1
self._std_offset = datetime.timedelta(minutes=stdoffset)
self._dst_offset = datetime.timedelta(minutes=dstoffset)
# for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
(self._stdmonth,
self._stddayofweek, # Sunday = 0
self._stdweeknumber, # Last = 5
self._stdhour,
self._stdminute) = tup[4:9]
(self._dstmonth,
self._dstdayofweek, # Sunday = 0
self._dstweeknumber, # Last = 5
self._dsthour,
self._dstminute) = tup[12:17]
self._dst_base_offset_ = self._dst_offset - self._std_offset
self.hasdst = self._get_hasdst()
def __repr__(self):
return "tzwin(%s)" % repr(self._name)
def __reduce__(self):
return (self.__class__, (self._name,))
class tzwinlocal(tzwinbase):
"""
Class representing the local time zone information in the Windows registry
While :class:`dateutil.tz.tzlocal` makes system calls (via the :mod:`time`
module) to retrieve time zone information, ``tzwinlocal`` retrieves the
rules directly from the Windows registry and creates an object like
:class:`dateutil.tz.tzwin`.
Because Windows does not have an equivalent of :func:`time.tzset`, on
Windows, :class:`dateutil.tz.tzlocal` instances will always reflect the
time zone settings *at the time that the process was started*, meaning
changes to the machine's time zone settings during the run of a program
on Windows will **not** be reflected by :class:`dateutil.tz.tzlocal`.
Because ``tzwinlocal`` reads the registry directly, it is unaffected by
this issue.
"""
def __init__(self):
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey:
keydict = valuestodict(tzlocalkey)
self._std_abbr = keydict["StandardName"]
self._dst_abbr = keydict["DaylightName"]
try:
tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME,
sn=self._std_abbr)
with winreg.OpenKey(handle, tzkeyname) as tzkey:
_keydict = valuestodict(tzkey)
self._display = _keydict["Display"]
except OSError:
self._display = None
stdoffset = -keydict["Bias"]-keydict["StandardBias"]
dstoffset = stdoffset-keydict["DaylightBias"]
self._std_offset = datetime.timedelta(minutes=stdoffset)
self._dst_offset = datetime.timedelta(minutes=dstoffset)
# For reasons unclear, in this particular key, the day of week has been
# moved to the END of the SYSTEMTIME structure.
tup = struct.unpack("=8h", keydict["StandardStart"])
(self._stdmonth,
self._stdweeknumber, # Last = 5
self._stdhour,
self._stdminute) = tup[1:5]
self._stddayofweek = tup[7]
tup = struct.unpack("=8h", keydict["DaylightStart"])
(self._dstmonth,
self._dstweeknumber, # Last = 5
self._dsthour,
self._dstminute) = tup[1:5]
self._dstdayofweek = tup[7]
self._dst_base_offset_ = self._dst_offset - self._std_offset
self.hasdst = self._get_hasdst()
def __repr__(self):
return "tzwinlocal()"
def __str__(self):
# str will return the standard name, not the daylight name.
return "tzwinlocal(%s)" % repr(self._std_abbr)
def __reduce__(self):
return (self.__class__, ())
def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
""" dayofweek == 0 means Sunday, whichweek 5 means last instance """
first = datetime.datetime(year, month, 1, hour, minute)
# This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6),
# Because 7 % 7 = 0
weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
wd = weekdayone + ((whichweek - 1) * ONEWEEK)
if (wd.month != month):
wd -= ONEWEEK
return wd
def valuestodict(key):
"""Convert a registry key's values to a dictionary."""
dout = {}
size = winreg.QueryInfoKey(key)[1]
tz_res = None
for i in range(size):
key_name, value, dtype = winreg.EnumValue(key, i)
if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN:
# If it's a DWORD (32-bit integer), it's stored as unsigned - convert
# that to a proper signed integer
if value & (1 << 31):
value = value - (1 << 32)
elif dtype == winreg.REG_SZ:
# If it's a reference to the tzres DLL, load the actual string
if value.startswith('@tzres'):
tz_res = tz_res or tzres()
value = tz_res.name_from_string(value)
value = value.rstrip('\x00') # Remove trailing nulls
dout[key_name] = value
return dout

View File

@ -0,0 +1,2 @@
# tzwin has moved to dateutil.tz.win
from .tz.win import *

View File

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
"""
This module offers general convenience and utility functions for dealing with
datetimes.
.. versionadded:: 2.7.0
"""
from __future__ import unicode_literals
from datetime import datetime, time
def today(tzinfo=None):
"""
Returns a :py:class:`datetime` representing the current day at midnight
:param tzinfo:
The time zone to attach (also used to determine the current day).
:return:
A :py:class:`datetime.datetime` object representing the current day
at midnight.
"""
dt = datetime.now(tzinfo)
return datetime.combine(dt.date(), time(0, tzinfo=tzinfo))
def default_tzinfo(dt, tzinfo):
"""
Sets the ``tzinfo`` parameter on naive datetimes only
This is useful for example when you are provided a datetime that may have
either an implicit or explicit time zone, such as when parsing a time zone
string.
.. doctest::
>>> from dateutil.tz import tzoffset
>>> from dateutil.parser import parse
>>> from dateutil.utils import default_tzinfo
>>> dflt_tz = tzoffset("EST", -18000)
>>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz))
2014-01-01 12:30:00+00:00
>>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz))
2014-01-01 12:30:00-05:00
:param dt:
The datetime on which to replace the time zone
:param tzinfo:
The :py:class:`datetime.tzinfo` subclass instance to assign to
``dt`` if (and only if) it is naive.
:return:
Returns an aware :py:class:`datetime.datetime`.
"""
if dt.tzinfo is not None:
return dt
else:
return dt.replace(tzinfo=tzinfo)
def within_delta(dt1, dt2, delta):
"""
Useful for comparing two datetimes that may have a negligible difference
to be considered equal.
"""
delta = abs(delta)
difference = dt1 - dt2
return -delta <= difference <= delta

View File

@ -0,0 +1,167 @@
# -*- coding: utf-8 -*-
import warnings
import json
from tarfile import TarFile
from pkgutil import get_data
from io import BytesIO
from dateutil.tz import tzfile as _tzfile
__all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"]
ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
METADATA_FN = 'METADATA'
class tzfile(_tzfile):
def __reduce__(self):
return (gettz, (self._filename,))
def getzoneinfofile_stream():
try:
return BytesIO(get_data(__name__, ZONEFILENAME))
except IOError as e: # TODO switch to FileNotFoundError?
warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
return None
class ZoneInfoFile(object):
def __init__(self, zonefile_stream=None):
if zonefile_stream is not None:
with TarFile.open(fileobj=zonefile_stream) as tf:
self.zones = {zf.name: tzfile(tf.extractfile(zf), filename=zf.name)
for zf in tf.getmembers()
if zf.isfile() and zf.name != METADATA_FN}
# deal with links: They'll point to their parent object. Less
# waste of memory
links = {zl.name: self.zones[zl.linkname]
for zl in tf.getmembers() if
zl.islnk() or zl.issym()}
self.zones.update(links)
try:
metadata_json = tf.extractfile(tf.getmember(METADATA_FN))
metadata_str = metadata_json.read().decode('UTF-8')
self.metadata = json.loads(metadata_str)
except KeyError:
# no metadata in tar file
self.metadata = None
else:
self.zones = {}
self.metadata = None
def get(self, name, default=None):
"""
Wrapper for :func:`ZoneInfoFile.zones.get`. This is a convenience method
for retrieving zones from the zone dictionary.
:param name:
The name of the zone to retrieve. (Generally IANA zone names)
:param default:
The value to return in the event of a missing key.
.. versionadded:: 2.6.0
"""
return self.zones.get(name, default)
# The current API has gettz as a module function, although in fact it taps into
# a stateful class. So as a workaround for now, without changing the API, we
# will create a new "global" class instance the first time a user requests a
# timezone. Ugly, but adheres to the api.
#
# TODO: Remove after deprecation period.
_CLASS_ZONE_INSTANCE = []
def get_zonefile_instance(new_instance=False):
"""
This is a convenience function which provides a :class:`ZoneInfoFile`
instance using the data provided by the ``dateutil`` package. By default, it
caches a single instance of the ZoneInfoFile object and returns that.
:param new_instance:
If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
used as the cached instance for the next call. Otherwise, new instances
are created only as necessary.
:return:
Returns a :class:`ZoneInfoFile` object.
.. versionadded:: 2.6
"""
if new_instance:
zif = None
else:
zif = getattr(get_zonefile_instance, '_cached_instance', None)
if zif is None:
zif = ZoneInfoFile(getzoneinfofile_stream())
get_zonefile_instance._cached_instance = zif
return zif
def gettz(name):
"""
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
:param name:
An IANA-style time zone name, as found in the zoneinfo file.
:return:
Returns a :class:`dateutil.tz.tzfile` time zone object.
.. warning::
It is generally inadvisable to use this function, and it is only
provided for API compatibility with earlier versions. This is *not*
equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
time zone based on the inputs, favoring system zoneinfo. This is ONLY
for accessing the dateutil-specific zoneinfo (which may be out of
date compared to the system zoneinfo).
.. deprecated:: 2.6
If you need to use a specific zoneinfofile over the system zoneinfo,
instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
:func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
Use :func:`get_zonefile_instance` to retrieve an instance of the
dateutil-provided zoneinfo.
"""
warnings.warn("zoneinfo.gettz() will be removed in future versions, "
"to use the dateutil-provided zoneinfo files, instantiate a "
"ZoneInfoFile object and use ZoneInfoFile.zones.get() "
"instead. See the documentation for details.",
DeprecationWarning)
if len(_CLASS_ZONE_INSTANCE) == 0:
_CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
return _CLASS_ZONE_INSTANCE[0].zones.get(name)
def gettz_db_metadata():
""" Get the zonefile metadata
See `zonefile_metadata`_
:returns:
A dictionary with the database metadata
.. deprecated:: 2.6
See deprecation warning in :func:`zoneinfo.gettz`. To get metadata,
query the attribute ``zoneinfo.ZoneInfoFile.metadata``.
"""
warnings.warn("zoneinfo.gettz_db_metadata() will be removed in future "
"versions, to use the dateutil-provided zoneinfo files, "
"ZoneInfoFile object and query the 'metadata' attribute "
"instead. See the documentation for details.",
DeprecationWarning)
if len(_CLASS_ZONE_INSTANCE) == 0:
_CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
return _CLASS_ZONE_INSTANCE[0].metadata

View File

@ -0,0 +1,75 @@
import logging
import os
import tempfile
import shutil
import json
from subprocess import check_call, check_output
from tarfile import TarFile
from dateutil.zoneinfo import METADATA_FN, ZONEFILENAME
def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None):
"""Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*
filename is the timezone tarball from ``ftp.iana.org/tz``.
"""
tmpdir = tempfile.mkdtemp()
zonedir = os.path.join(tmpdir, "zoneinfo")
moduledir = os.path.dirname(__file__)
try:
with TarFile.open(filename) as tf:
for name in zonegroups:
tf.extract(name, tmpdir)
filepaths = [os.path.join(tmpdir, n) for n in zonegroups]
_run_zic(zonedir, filepaths)
# write metadata file
with open(os.path.join(zonedir, METADATA_FN), 'w') as f:
json.dump(metadata, f, indent=4, sort_keys=True)
target = os.path.join(moduledir, ZONEFILENAME)
with TarFile.open(target, "w:%s" % format) as tf:
for entry in os.listdir(zonedir):
entrypath = os.path.join(zonedir, entry)
tf.add(entrypath, entry)
finally:
shutil.rmtree(tmpdir)
def _run_zic(zonedir, filepaths):
"""Calls the ``zic`` compiler in a compatible way to get a "fat" binary.
Recent versions of ``zic`` default to ``-b slim``, while older versions
don't even have the ``-b`` option (but default to "fat" binaries). The
current version of dateutil does not support Version 2+ TZif files, which
causes problems when used in conjunction with "slim" binaries, so this
function is used to ensure that we always get a "fat" binary.
"""
try:
help_text = check_output(["zic", "--help"])
except OSError as e:
_print_on_nosuchfile(e)
raise
if b"-b " in help_text:
bloat_args = ["-b", "fat"]
else:
bloat_args = []
check_call(["zic"] + bloat_args + ["-d", zonedir] + filepaths)
def _print_on_nosuchfile(e):
"""Print helpful troubleshooting message
e is an exception raised by subprocess.check_call()
"""
if e.errno == 2:
logging.error(
"Could not find zic. Perhaps you need to install "
"libc-bin or some other package that provides it, "
"or it's not in your PATH?")

View File

@ -0,0 +1,167 @@
# coding=utf-8
from __future__ import absolute_import
import threading
import time
import octoprint.plugin
from octoprint.events import Events
from .ftpsclient import IoTFTPSClient
class BambuPrintPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.SimpleApiPlugin):
def get_assets(self):
return {'js': ["js/bambu_printer.js"]}
def get_template_configs(self):
return [{"type": "settings", "custom_bindings": True}] #, {"type": "generic", "custom_bindings": True, "template": "bambu_printer.jinja2"}]
def get_settings_defaults(self):
return {"device_type": "X1C",
"serial": "",
"host": "",
"access_code": "",
"username": "bblp",
"timelapse": False,
"bed_leveling": True,
"flow_cali": False,
"vibration_cali": True,
"layer_inspect": True,
"use_ams": False,
"local_mqtt": True,
"region": "",
"email": "",
"auth_token": "",
"always_use_default_options": False
}
def is_api_adminonly(self):
return True
def get_api_commands(self):
return {"register": ["email", "password", "region", "auth_token"]}
def on_api_command(self, command, data):
import flask
if command == "register":
if "email" in data and "password" in data and "region" in data and "auth_token" in data:
self._logger.info(f"Registering user {data['email']}")
from pybambu import BambuCloud
bambu_cloud = BambuCloud(data["region"], data["email"], data["password"], data["auth_token"])
bambu_cloud.login(data["region"], data["email"], data["password"])
return flask.jsonify({"auth_token": bambu_cloud.auth_token, "username": bambu_cloud.username})
def on_event(self, event, payload):
if event == Events.TRANSFER_DONE:
self._printer.commands("M20 L T", force=True)
def support_3mf_files(self):
return {'machinecode': {'3mf': ["3mf"]}}
def upload_to_sd(self, printer, filename, path, sd_upload_started, sd_upload_succeeded, sd_upload_failed, *args, **kwargs):
self._logger.debug(f"Starting upload from {filename} to {filename}")
sd_upload_started(filename, filename)
def process():
host = self._settings.get(["host"])
access_code = self._settings.get(["access_code"])
elapsed = time.monotonic()
try:
ftp = IoTFTPSClient(f"{host}", 990, "bblp", f"{access_code}", ssl_implicit=True)
if ftp.upload_file(path, f"{filename}"):
elapsed = time.monotonic() - elapsed
sd_upload_succeeded(filename, filename, elapsed)
# remove local file after successful upload to Bambu
# self._file_manager.remove_file("local", filename)
else:
raise Exception("upload failed")
except Exception as e:
elapsed = time.monotonic() - elapsed
sd_upload_failed(filename, filename, elapsed)
self._logger.debug(f"Error uploading file {filename}")
thread = threading.Thread(target=process)
thread.daemon = True
thread.start()
return filename
def get_template_vars(self):
return {"plugin_version": self._plugin_version}
def virtual_printer_factory(self, comm_instance, port, baudrate, read_timeout):
if not port == "BAMBU":
return None
if self._settings.get(["serial"]) == "" or self._settings.get(["host"]) == "" or self._settings.get(["access_code"]) == "":
return None
import logging.handlers
from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
seriallog_handler = CleaningTimedRotatingFileHandler(
self._settings.get_plugin_logfile_path(postfix="serial"),
when="D",
backupCount=3,
)
seriallog_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
seriallog_handler.setLevel(logging.DEBUG)
from . import virtual
serial_obj = virtual.BambuPrinter(
self._settings,
self._printer_profile_manager,
data_folder=self.get_plugin_data_folder(),
seriallog_handler=seriallog_handler,
read_timeout=float(read_timeout),
faked_baudrate=baudrate,
)
return serial_obj
def get_additional_port_names(self, *args, **kwargs):
if self._settings.get(["serial"]) != "" and self._settings.get(["host"]) != "" and self._settings.get(["access_code"]) != "":
return ["BAMBU"]
else:
return []
def get_update_information(self):
return {'bambu_printer': {'displayName': "Bambu Printer",
'displayVersion': self._plugin_version,
'type': "github_release",
'user': "jneilliii",
'repo': "OctoPrint-BambuPrinter",
'current': self._plugin_version,
'stable_branch': {'name': "Stable",
'branch': "master",
'comittish': ["master"]},
'prerelease_branches': [
{'name': "Release Candidate",
'branch': "rc",
'comittish': ["rc", "master"]}
],
'pip': "https://github.com/jneilliii/OctoPrint-BambuPrinter/archive/{target_version}.zip"}}
__plugin_name__ = "Bambu Printer"
__plugin_pythoncompat__ = ">=3.7,<4"
def __plugin_load__():
plugin = BambuPrintPlugin()
global __plugin_implementation__
__plugin_implementation__ = plugin
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.transport.serial.factory": __plugin_implementation__.virtual_printer_factory,
"octoprint.comm.transport.serial.additional_port_names": __plugin_implementation__.get_additional_port_names,
"octoprint.filemanager.extension_tree": __plugin_implementation__.support_3mf_files,
"octoprint.printer.sdcardupload": __plugin_implementation__.upload_to_sd,
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information,
}

View File

@ -0,0 +1 @@
from .ftpsclient import IoTFTPSClient

View File

@ -0,0 +1,228 @@
"""
Based on: <https://github.com/dgonzo27/py-iot-utils>
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
wrapper for FTPS server interactions
"""
import ftplib
import os
import socket
import ssl
from typing import Optional, Union, List
from contextlib import redirect_stdout
import io
import re
class ImplicitTLS(ftplib.FTP_TLS):
"""ftplib.FTP_TLS sub-class to support implicit SSL FTPS"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._sock = None
@property
def sock(self):
"""return socket"""
return self._sock
@sock.setter
def sock(self, value):
"""wrap and set SSL socket"""
if value is not None and not isinstance(value, ssl.SSLSocket):
value = self.context.wrap_socket(value)
self._sock = value
def ntransfercmd(self, cmd, rest=None):
conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest)
if self._prot_p:
conn = self.context.wrap_socket(conn,
server_hostname=self.host,
session=self.sock.session) # this is the fix
return conn, size
class IoTFTPSClient:
"""iot ftps ftpsclient"""
ftps_host: str
ftps_port: int
ftps_user: str
ftps_pass: str
ssl_implicit: bool
ftps_session: Union[ftplib.FTP, ImplicitTLS]
last_error: Optional[str] = None
welcome: str
def __init__(
self,
ftps_host: str,
ftps_port: Optional[int] = 21,
ftps_user: Optional[str] = "",
ftps_pass: Optional[str] = "",
ssl_implicit: Optional[bool] = False,
) -> None:
self.ftps_host = ftps_host
self.ftps_port = ftps_port
self.ftps_user = ftps_user
self.ftps_pass = ftps_pass
self.ssl_implicit = ssl_implicit
self.instantiate_ftps_session()
def __repr__(self) -> str:
return (
"IoT FTPS Client\n"
"--------------------\n"
f"host: {self.ftps_host}\n"
f"port: {self.ftps_port}\n"
f"user: {self.ftps_user}\n"
f"ssl: {self.ssl_implicit}"
)
def instantiate_ftps_session(self) -> None:
"""init ftps_session based on input params"""
self.ftps_session = ImplicitTLS() if self.ssl_implicit else ftplib.FTP()
self.ftps_session.set_debuglevel(0)
self.welcome = self.ftps_session.connect(
host=self.ftps_host, port=self.ftps_port)
if self.ftps_user and self.ftps_pass:
self.ftps_session.login(user=self.ftps_user, passwd=self.ftps_pass)
else:
self.ftps_session.login()
if self.ssl_implicit:
self.ftps_session.prot_p()
def disconnect(self) -> None:
"""disconnect the current session from the ftps server"""
self.ftps_session.close()
def download_file(self, source: str, dest: str):
"""download a file to a path on the local filesystem"""
with open(dest, "wb") as file:
self.ftps_session.retrbinary(f"RETR {source}", file.write)
def upload_file(self, source: str, dest: str, callback=None) -> bool:
"""upload a file to a path inside the FTPS server"""
file_size = os.path.getsize(source)
block_size = max(file_size // 100, 8192)
rest = None
try:
# Taken from ftplib.storbinary but with custom ssl handling
# due to the shitty bambu p1p ftps server TODO fix properly.
with open(source, "rb") as fp:
self.ftps_session.voidcmd('TYPE I')
with self.ftps_session.transfercmd(f"STOR {dest}", rest) as conn:
while 1:
buf = fp.read(block_size)
if not buf:
break
conn.sendall(buf)
if callback:
callback(buf)
# shutdown ssl layer
if ftplib._SSLSocket is not None and isinstance(conn, ftplib._SSLSocket):
# Yeah this is suposed to be conn.unwrap
# But since we operate in prot p mode
# we can close the connection always.
# This is cursed but it works.
if "vsFTPd" in self.welcome:
conn.unwrap()
else:
conn.shutdown(socket.SHUT_RDWR)
return True
except Exception as ex:
print(f"unexpected exception occurred: {ex}")
pass
return False
def delete_file(self, path: str) -> bool:
"""delete a file from under a path inside the FTPS server"""
try:
self.ftps_session.delete(path)
return True
except Exception as ex:
print(f"unexpected exception occurred: {ex}")
pass
return False
def move_file(self, source: str, dest: str):
"""move a file inside the FTPS server to another path inside the FTPS server"""
self.ftps_session.rename(source, dest)
def mkdir(self, path: str) -> str:
return self.ftps_session.mkd(path)
def list_files(self, path: str, file_pattern: Optional[str] = None) -> Union[List[str], None]:
"""list files under a path inside the FTPS server"""
try:
files = self.ftps_session.nlst(path)
if not files:
return
if file_pattern:
return [f for f in files if file_pattern in f]
return files
except Exception as ex:
print(f"unexpected exception occurred: {ex}")
pass
return
def list_files_ex(self, path: str) -> Union[list[str], None]:
"""list files under a path inside the FTPS server"""
try:
f = io.StringIO()
with redirect_stdout(f):
self.ftps_session.dir(path)
s = f.getvalue()
files = []
for row in s.split("\n"):
if len(row) <= 0: continue
attribs = row.split(" ")
match = re.search(r".*\ (\d\d\:\d\d|\d\d\d\d)\ (.*)", row)
name = ""
if match:
name = match.groups(1)[1]
else:
name = attribs[len(attribs) - 1]
file = ( attribs[0], name )
files.append(file)
return files
except Exception as ex:
print(f"unexpected exception occurred: [{ex}]")
pass
return

View File

@ -0,0 +1,92 @@
/*
* View model for OctoPrint-BambuPrinter
*
* Author: jneilliii
* License: AGPLv3
*/
$(function () {
function Bambu_printerViewModel(parameters) {
var self = this;
self.settingsViewModel = parameters[0];
self.filesViewModel = parameters[1];
self.getAuthToken = function (data) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token("");
OctoPrint.simpleApiCommand("bambu_printer", "register", {
"email": self.settingsViewModel.settings.plugins.bambu_printer.email(),
"password": $("#bambu_cloud_password").val(),
"region": self.settingsViewModel.settings.plugins.bambu_printer.region(),
"auth_token": self.settingsViewModel.settings.plugins.bambu_printer.auth_token()
})
.done(function (response) {
console.log(response);
self.settingsViewModel.settings.plugins.bambu_printer.auth_token(response.auth_token);
self.settingsViewModel.settings.plugins.bambu_printer.username(response.username);
});
};
/*$('#files div.upload-buttons > span.fileinput-button:first, #files div.folder-button').remove();
$('#files div.upload-buttons > span.fileinput-button:first').removeClass('span6').addClass('input-block-level');
self.onBeforePrintStart = function(start_print_command) {
let confirmation_html = '' +
' <div class="row-fluid form-vertical">\n' +
' <div class="control-group">\n' +
' <label class="control-label">' + gettext("Plate Number") + '</label>\n' +
' <div class="controls">\n' +
' <input type="number" min="1" value="1" id="bambu_printer_plate_number" class="input-mini">\n' +
' </div>\n' +
' </div>\n' +
' </div>';
if(!self.settingsViewModel.settings.plugins.bambu_printer.always_use_default_options()){
confirmation_html += '\n' +
' <div class="row-fluid">\n' +
' <div class="span6">\n' +
' <label class="checkbox"><input id="bambu_printer_timelapse" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.timelapse()) ? ' checked' : '') + '> ' + gettext("Enable timelapse") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_bed_leveling" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.bed_leveling()) ? ' checked' : '') + '> ' + gettext("Enable bed leveling") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_flow_cali" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.flow_cali()) ? ' checked' : '') + '> ' + gettext("Enable flow calibration") + '</label>\n' +
' </div>\n' +
' <div class="span6">\n' +
' <label class="checkbox"><input id="bambu_printer_vibration_cali" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.vibration_cali()) ? ' checked' : '') + '> ' + gettext("Enable vibration calibration") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_layer_inspect" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.layer_inspect()) ? ' checked' : '') + '> ' + gettext("Enable first layer inspection") + '</label>\n' +
' <label class="checkbox"><input id="bambu_printer_use_ams" type="checkbox"' + ((self.settingsViewModel.settings.plugins.bambu_printer.use_ams()) ? ' checked' : '') + '> ' + gettext("Use AMS") + '</label>\n' +
' </div>\n' +
' </div>\n';
}
showConfirmationDialog({
title: "Bambu Print Options",
html: confirmation_html,
cancel: gettext("Cancel"),
proceed: [gettext("Print"), gettext("Always")],
onproceed: function (idx) {
if(idx === 1){
self.settingsViewModel.settings.plugins.bambu_printer.timelapse($('#bambu_printer_timelapse').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.bed_leveling($('#bambu_printer_bed_leveling').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.flow_cali($('#bambu_printer_flow_cali').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.vibration_cali($('#bambu_printer_vibration_cali').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.layer_inspect($('#bambu_printer_layer_inspect').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.use_ams($('#bambu_printer_use_ams').is(':checked'));
self.settingsViewModel.settings.plugins.bambu_printer.always_use_default_options(true);
self.settingsViewModel.saveData();
}
// replace this with our own print command API call?
start_print_command();
},
nofade: true
});
return false;
};*/
}
OCTOPRINT_VIEWMODELS.push({
construct: Bambu_printerViewModel,
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
dependencies: ["settingsViewModel", "filesViewModel"],
// Elements to bind to, e.g. #settings_plugin_bambu_printer, #tab_plugin_bambu_printer, ...
elements: ["#bambu_printer_print_options", "#settings_plugin_bambu_printer"]
});
});

View File

@ -0,0 +1,78 @@
<h3>Bambu Printer Settings <small>{{ _('Version') }} {{ plugin_bambu_printer_plugin_version }}</small></h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Device Type') }}</label>
<div class="controls">
<select class="input-block-level" data-bind="options: ['A1', 'A1MINI', 'P1P', 'P1S', 'X1', 'X1C'], value: settingsViewModel.settings.plugins.bambu_printer.device_type, allowUnset: true">
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('IP Address') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.host" placeholder="192.168.0.2" title="{{ _('IP address or hostname of the printer') }}"></input>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Serial Number') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.serial" title="{{ _('Serial number of printer') }}"></input>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Access Code') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.access_code" title="{{ _('Access code of printer') }}"></input>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.local_mqtt"> {{ _('Use Local Access, disable for cloud connection') }}</label>
</div>
</div>
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<label class="control-label">{{ _('Region') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.region" title="{{ _('Region used to connect, ie China, US') }}"></input>
</div>
</div>
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<label class="control-label">{{ _('Email') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.email" title="{{ _('Registered email address') }}"></input>
</div>
</div>
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<label class="control-label">{{ _('Password') }}</label>
<div class="controls">
<div class="input-block-level input-append">
<input id="bambu_cloud_password" type="password" class="input-text input-block-level" title="{{ _('Password to generate Auth Token') }}"></input>
<span class="btn btn-primary add-on" data-bind="click: getAuthToken">{{ _('Login') }}</span>
</div>
</div>
</div>
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<label class="control-label">{{ _('Auth Token') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.auth_token" title="{{ _('Auth Token') }}"></input>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Default Print Options') }}</label>
<div class="controls">
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.timelapse"> {{ _('Enable timelapse') }}</label>
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.bed_leveling"> {{ _('Enable bed leveling') }}</label>
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.flow_cali"> {{ _('Enable flow calibration') }}</label>
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.vibration_cali"> {{ _('Enable vibration calibration') }}</label>
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.layer_inspect"> {{ _('Enable first layer inspection') }}</label>
<label class="checkbox"><input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.bambu_printer.use_ams"> {{ _('Use AMS') }}</label>
</div>
</div>
{#<div class="control-group">
<label class="control-label">{{ _('Always Use Default') }}</label>
<div class="controls">
<label class="checkbox"><input type="checkbox" data-bind="checked: settings.plugins.bambu_printer.always_use_default_options"> </label>
</div>
</div>#}
</form>

View File

@ -0,0 +1,5 @@
__version__ = "1.6.1"
class MQTTException(Exception):
pass

Some files were not shown because too many files have changed in this diff Show More