♻️ Py3: Remove use of glob_escape & monotonic_time & mark deprecated

Those are natively available in Python 3.
This commit is contained in:
Gina Häußge committed 2020-10-21 19:01:02 +02:00
1 parent d2298a8092
commit ac347c4e06
16 files changed
+101 -98

No files matched your search

+6 -5
View File
@@ -5,6 +5,7 @@ import hashlib
import io
import logging
import os
import time
import uuid
# noinspection PyCompatibility
@@ -20,7 +21,7 @@ from octoprint.access.permissions import OctoPrintPermission, Permissions
from octoprint.settings import settings as s
from octoprint.util import atomic_write, deprecated, generate_api_key
from octoprint.util import get_fully_qualified_classname as fqcn
from octoprint.util import monotonic_time, to_bytes
from octoprint.util import to_bytes
class UserManager(GroupChangeListener):
@@ -131,7 +132,7 @@ class UserManager(GroupChangeListener):
for session, user in list(self._session_users_by_session.items()):
if not isinstance(user, SessionUser):
continue
if user.created + (24 * 60 * 60) < monotonic_time():
if user.created + (24 * 60 * 60) < time.monotonic():
self._logger.info(
"Cleaning up user session {} for user {}".format(
session, user.get_id()
@@ -1374,8 +1375,8 @@ class SessionUser(wrapt.ObjectProxy):
wrapt.ObjectProxy.__init__(self, user)
self._self_session = "".join("%02X" % z for z in bytes(uuid.uuid4().bytes))
self._self_created = monotonic_time()
self._self_touched = monotonic_time()
self._self_created = time.monotonic()
self._self_touched = time.monotonic()
@property
def session(self):
@@ -1390,7 +1391,7 @@ class SessionUser(wrapt.ObjectProxy):
return self._self_touched
def touch(self):
self._self_touched = monotonic_time()
self._self_touched = time.monotonic()
@deprecated(
"SessionUser.get_session() has been deprecated, use SessionUser.session instead",
+2 -3
View File
@@ -48,7 +48,6 @@ def gcode_command(
import yaml
from octoprint.util import monotonic_time
from octoprint.util.gcodeInterpreter import gcode
throttle_callback = None
@@ -68,7 +67,7 @@ def gcode_command(
if len(offsets) < maxt:
offsets += [(0, 0)] * (maxt - len(offsets))
start_time = monotonic_time()
start_time = time.monotonic()
progress_callback = None
if progress:
@@ -88,7 +87,7 @@ def gcode_command(
g90_extruder=g90_extruder,
)
click.echo("DONE:{}s".format(monotonic_time() - start_time))
click.echo("DONE:{}s".format(time.monotonic() - start_time))
click.echo("RESULTS:")
click.echo(
yaml.safe_dump(
+3 -2
View File
@@ -5,6 +5,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
import io
import logging
import os
import time
from collections import namedtuple
import octoprint.plugin
@@ -472,7 +473,7 @@ class FileManager:
analysis=_analysis,
)
end_time = octoprint.util.monotonic_time()
end_time = time.monotonic()
eventManager().fire(
Events.SLICING_DONE,
{
@@ -503,7 +504,7 @@ class FileManager:
slicer = self._slicing_manager.get_slicer(slicer_name)
start_time = octoprint.util.monotonic_time()
start_time = time.monotonic()
eventManager().fire(
Events.SLICING_STARTED,
{
+2 -3
View File
@@ -14,7 +14,6 @@ from octoprint.events import Events, eventManager
from octoprint.settings import settings
from octoprint.util import dict_merge
from octoprint.util import get_fully_qualified_classname as fqcn
from octoprint.util import monotonic_time
from octoprint.util.platform import CLOSE_FDS
@@ -290,7 +289,7 @@ class AbstractAnalysisQueue:
self._current_progress = 0
try:
start_time = monotonic_time()
start_time = time.monotonic()
self._logger.info("Starting analysis of {}".format(entry))
eventManager().fire(
Events.METADATA_ANALYSIS_STARTED,
@@ -307,7 +306,7 @@ class AbstractAnalysisQueue:
result = self._do_analysis()
self._logger.info(
"Analysis of entry {} finished, needed {:.2f}s".format(
entry, monotonic_time() - start_time
entry, time.monotonic() - start_time
)
)
self._finished_callback(self._current, result)
@@ -25,7 +25,7 @@ from octoprint.server.util.flask import (
no_firstrun_access,
with_revalidation_checking,
)
from octoprint.util import count, monotonic_time, utmify
from octoprint.util import count, utmify
PY2 = sys.version_info[0] < 3
@@ -452,12 +452,12 @@ class AnnouncementPlugin(
url = config["url"]
try:
start = monotonic_time()
start = time.monotonic()
r = requests.get(url, timeout=30)
r.raise_for_status()
self._logger.info(
"Loaded channel {} from {} in {:.2}s".format(
key, config["url"], monotonic_time() - start
key, config["url"], time.monotonic() - start
)
)
except Exception:
+4 -3
View File
@@ -1,6 +1,7 @@
import io
import os
import threading
import time
from collections import defaultdict
import flask
@@ -13,7 +14,7 @@ from octoprint.access.permissions import Permissions
from octoprint.server import NO_CONTENT, admin_permission, current_user
from octoprint.server.util.flask import no_firstrun_access, restricted_access
from octoprint.settings import valid_boolean_trues
from octoprint.util import ResettableTimer, atomic_write, generate_api_key, monotonic_time
from octoprint.util import ResettableTimer, atomic_write, generate_api_key
CUTOFF_TIME = 10 * 60 # 10min
POLL_TIMEOUT = 5 # 5 seconds
@@ -29,7 +30,7 @@ class PendingDecision:
self.app_token = app_token
self.user_id = user_id
self.user_token = user_token
self.created = monotonic_time()
self.created = time.monotonic()
if callable(timeout_callback):
self.poll_timeout = ResettableTimer(
@@ -339,7 +340,7 @@ class AppKeysPlugin(
def _remove_stale_pending(self):
with self._pending_lock:
cutoff = monotonic_time() - CUTOFF_TIME
cutoff = time.monotonic() - CUTOFF_TIME
len_before = len(self._pending_decisions)
self._pending_decisions = list(
filter(lambda x: x.created >= cutoff, self._pending_decisions)
+2 -3
View File
@@ -596,8 +596,7 @@ class DiscoveryPlugin(
if (
alive
and self._ssdp_last_notify + self._ssdp_notify_timeout
> octoprint.util.monotonic_time()
and self._ssdp_last_notify + self._ssdp_notify_timeout > time.monotonic()
):
# we just sent an alive, no need to send another one now
return
@@ -664,7 +663,7 @@ class DiscoveryPlugin(
except Exception:
pass
self._ssdp_last_notify = octoprint.util.monotonic_time()
self._ssdp_last_notify = time.monotonic()
def _ssdp_monitor(self, timeout=5):
"""
@@ -4,8 +4,6 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
import time
from octoprint.util import monotonic_time
def can_perform_update(target, check, online=True):
return True
@@ -14,9 +12,9 @@ def can_perform_update(target, check, online=True):
def perform_update(target, check, target_version, log_cb=None, online=True):
duration = check.get("duration", 30)
now = monotonic_time()
now = time.monotonic()
end = now + duration
while now < end:
log_cb(["{}s left...".format(end - now)], prefix=">", stream="output")
time.sleep(5)
now = monotonic_time()
now = time.monotonic()
+4 -3
View File
@@ -5,6 +5,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
import concurrent.futures
import hashlib
import logging
import time
from urllib.parse import urlencode
import requests
@@ -12,7 +13,7 @@ from flask_babel import gettext
import octoprint.plugin
from octoprint.events import Events
from octoprint.util import RepeatedTimer, monotonic_time
from octoprint.util import RepeatedTimer
from octoprint.util.version import get_octoprint_version_string
TRACKING_URL = "https://tracking.octoprint.org/track/{id}/{event}/"
@@ -41,7 +42,7 @@ class TrackingPlugin(
self._record_next_firmware_info = False
self._startup_time = monotonic_time()
self._startup_time = time.monotonic()
def initialize(self):
self._init_id()
@@ -230,7 +231,7 @@ class TrackingPlugin(
if not self._settings.get_boolean(["enabled"]):
return
uptime = int(monotonic_time() - self._startup_time)
uptime = int(time.monotonic() - self._startup_time)
self._track("ping", octoprint_uptime=uptime)
def _track_pong(self):
@@ -18,13 +18,7 @@ from typing import Any
from serial import SerialTimeoutException
from octoprint.plugin import plugin_manager
from octoprint.util import (
RepeatedTimer,
get_dos_filename,
monotonic_time,
to_bytes,
to_unicode,
)
from octoprint.util import RepeatedTimer, get_dos_filename, to_bytes, to_unicode
# noinspection PyBroadException
@@ -110,7 +104,7 @@ class VirtualPrinter:
self.bedTargetTemp = 0.0
self.chamberTemp = self._ambient_temperature
self.chamberTargetTemp = 0.0
self.lastTempAt = monotonic_time()
self.lastTempAt = time.monotonic()
self._relative = True
self._lastX = 0.0
@@ -316,7 +310,7 @@ class VirtualPrinter:
pass
def _processIncoming(self):
next_wait_timeout = monotonic_time() + self._waitInterval
next_wait_timeout = time.monotonic() + self._waitInterval
buf = b""
while self.incoming is not None and not self._killed:
self._simulateTemps()
@@ -330,9 +324,9 @@ class VirtualPrinter:
data = to_bytes(data, encoding="ascii", errors="replace")
self.incoming.task_done()
except queue.Empty:
if self._sendWait and monotonic_time() > next_wait_timeout:
if self._sendWait and time.monotonic() > next_wait_timeout:
self._send("wait")
next_wait_timeout = monotonic_time() + self._waitInterval
next_wait_timeout = time.monotonic() + self._waitInterval
continue
except Exception:
if self.incoming is None:
@@ -348,7 +342,7 @@ class VirtualPrinter:
else:
continue
next_wait_timeout = monotonic_time() + self._waitInterval
next_wait_timeout = time.monotonic() + self._waitInterval
if data is None:
continue
@@ -831,8 +825,8 @@ class VirtualPrinter:
_timeout = float(matchS.group(1))
if self._sendBusy and self._busyInterval > 0:
until = monotonic_time() + _timeout
while monotonic_time() < until:
until = time.monotonic() + _timeout
while time.monotonic() < until:
time.sleep(self._busyInterval)
self._send("busy:processing")
else:
@@ -846,8 +840,8 @@ class VirtualPrinter:
timeout = 60
if self._sendBusy and self._busyInterval > 0:
until = monotonic_time() + timeout
while monotonic_time() < until:
until = time.monotonic() + timeout
while time.monotonic() < until:
time.sleep(self._busyInterval)
self._send("busy:processing")
else:
@@ -1545,7 +1539,7 @@ class VirtualPrinter:
# type: (str, bool) -> None
delta = 1
delay = 1
last_busy = monotonic_time()
last_busy = time.monotonic()
self._heatingUp = True
try:
@@ -1573,9 +1567,9 @@ class VirtualPrinter:
while not self._killed and self._heatingUp and test():
self._simulateTemps(delta=delta)
self._send(output())
if self._sendBusy and monotonic_time() - last_busy >= self._busyInterval:
if self._sendBusy and time.monotonic() - last_busy >= self._busyInterval:
self._send("echo:busy: processing")
last_busy = monotonic_time()
last_busy = time.monotonic()
time.sleep(delay)
except AttributeError:
if self.outgoing is not None:
@@ -1597,8 +1591,8 @@ class VirtualPrinter:
os.remove(file["path"])
def _simulateTemps(self, delta=0.5):
timeDiff = self.lastTempAt - monotonic_time()
self.lastTempAt = monotonic_time()
timeDiff = self.lastTempAt - time.monotonic()
self.lastTempAt = time.monotonic()
def simulate(actual, target, ambient):
if target > 0:
@@ -1820,9 +1814,9 @@ class CharCountingQueue(queue.Queue):
elif timeout < 0:
raise ValueError("'timeout' must be a positive number")
else:
endtime = monotonic_time() + timeout
endtime = time.monotonic() + timeout
while not self._will_it_fit(item):
remaining = endtime - monotonic_time()
remaining = endtime - time.monotonic()
if remaining <= 0.0:
raise queue.Full
self.not_full.wait(remaining)
+4 -4
View File
@@ -30,7 +30,7 @@ from octoprint.settings import settings
from octoprint.util import InvariantContainer
from octoprint.util import comm as comm
from octoprint.util import get_fully_qualified_classname as fqcn
from octoprint.util import monotonic_time, to_unicode
from octoprint.util import to_unicode
class Printer(PrinterInterface, comm.MachineComPrintCallback):
@@ -1852,7 +1852,7 @@ class StateMonitor:
self._state_lock = threading.Lock()
self._progress_lock = threading.Lock()
self._last_update = monotonic_time()
self._last_update = time.monotonic()
self._worker = threading.Thread(target=self._work)
self._worker.daemon = True
self._worker.start()
@@ -1918,7 +1918,7 @@ class StateMonitor:
while True:
self._change_event.wait()
now = monotonic_time()
now = time.monotonic()
delta = now - self._last_update
additional_wait_time = self._interval - delta
if additional_wait_time > 0:
@@ -1927,7 +1927,7 @@ class StateMonitor:
with self._state_lock:
data = self.get_current_data()
self._update_callback(data)
self._last_update = monotonic_time()
self._last_update = time.monotonic()
self._change_event.clear()
except Exception:
logging.getLogger(__name__).exception(
+2 -4
View File
@@ -1701,7 +1701,7 @@ class Server:
kwargs.update(additional_request_data)
try:
start = octoprint.util.monotonic_time()
start = time.monotonic()
if plugin:
logger.info(
"Preemptively caching {} (ui {}) for {!r}".format(
@@ -1724,9 +1724,7 @@ class Server:
app(builder.get_environ(), lambda *a, **kw: None)
logger.info(
"... done in {:.2f}s".format(
octoprint.util.monotonic_time() - start
)
"... done in {:.2f}s".format(time.monotonic() - start)
)
except Exception:
logger.exception(
+4 -3
View File
@@ -4,6 +4,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
import collections
import datetime
import fnmatch
import glob
import io
import logging
import os
@@ -23,7 +24,7 @@ from octoprint.events import Events, eventManager
from octoprint.plugin import plugin_manager
from octoprint.settings import settings
from octoprint.util import get_fully_qualified_classname as fqcn
from octoprint.util import monotonic_time, sv
from octoprint.util import sv
from octoprint.util.commandline import CommandlineCaller
try:
@@ -194,7 +195,7 @@ def get_unrendered_timelapses():
def delete_unrendered_timelapse(name):
global _cleanup_lock
pattern = "{}*.jpg".format(util.glob_escape(name))
pattern = "{}*.jpg".format(glob.escape(name))
basedir = settings().getBaseFolder("timelapse_tmp")
with _cleanup_lock:
@@ -853,7 +854,7 @@ class ZTimelapse(Timelapse):
return
# check if last picture has been less than min_delay ago, if so don't take a picture (anti vase mode...)
now = monotonic_time()
now = time.monotonic()
if (
self._min_delay
and self._last_snapshot
+19 -7
View File
@@ -9,6 +9,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
import collections
import contextlib
import copy
import glob
import io
import logging
import os
@@ -22,8 +23,6 @@ import time
import traceback
import warnings
from functools import wraps
from glob import escape
from time import monotonic as monotonic_time # noqa: F401
from typing import Union
import frozendict
@@ -87,10 +86,6 @@ def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
return s_or_u
to_native_str = to_unicode
"""Synonym for to_unicode, deprecated"""
def sortable_value(value, default_value=""):
if value is None:
return default_value
@@ -314,6 +309,12 @@ to_str = deprecated(
since="1.3.11",
)(to_bytes)
to_native_str = deprecated(
"to_native_str is no longer needed",
includedoc="to_native_str is no longer needed, use to_unicode",
since="2.0.0",
)(to_unicode)
def get_formatted_size(num):
"""
@@ -389,6 +390,13 @@ def get_formatted_datetime(d):
return d.strftime("%Y-%m-%d %H:%M")
monotonic_time = deprecated(
"monotonic_time is natively available as time.monotonic in Python 3",
includedoc="Replaced by :func:`time.monotonic`",
since="2.0.0",
)(time.monotonic)
def get_class(name):
"""
Retrieves the class object for a given fully qualified class name.
@@ -1277,7 +1285,11 @@ def is_hidden_path(path):
return False
glob_escape = escape
glob_escape = deprecated(
"glob_escape is available natively under Python 3 as glob.escape",
includedoc="Replaced by :func:`glob.escape`",
since="2.0.0",
)(glob.escape)
def thaw_frozendict(obj):
+24 -25
View File
@@ -39,7 +39,6 @@ from octoprint.util import (
filter_non_ascii,
filter_non_utf8,
get_exception_string,
monotonic_time,
sanitize_ascii,
to_unicode,
)
@@ -980,7 +979,7 @@ class MachineCom:
return None
else:
return (
monotonic_time()
time.monotonic()
- self._currentFile.getStartTime()
- self._pauseWaitTimeLost
)
@@ -1109,11 +1108,11 @@ class MachineCom:
self.sendGcodeScript("beforePrinterDisconnected")
if wait:
if timeout is not None:
stop = monotonic_time() + timeout
stop = time.monotonic() + timeout
while (
self._command_queue.unfinished_tasks
or self._send_queue.unfinished_tasks
) and monotonic_time() < stop:
) and time.monotonic() < stop:
time.sleep(0.1)
else:
self._command_queue.join()
@@ -1346,7 +1345,7 @@ class MachineCom:
if self._currentFile is None:
raise ValueError("No file selected for printing")
self._heatupWaitStartTime = None if not self._heating else monotonic_time()
self._heatupWaitStartTime = None if not self._heating else time.monotonic()
self._heatupWaitTimeLost = 0.0
self._pauseWaitStartTime = 0
self._pauseWaitTimeLost = 0.0
@@ -1763,7 +1762,7 @@ class MachineCom:
if not pause and self._state in valid_paused_states:
if self._pauseWaitStartTime:
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (
monotonic_time() - self._pauseWaitStartTime
time.monotonic() - self._pauseWaitStartTime
)
self._pauseWaitStartTime = None
@@ -1796,7 +1795,7 @@ class MachineCom:
elif pause and self._state in valid_running_states:
if not self._pauseWaitStartTime:
self._pauseWaitStartTime = monotonic_time()
self._pauseWaitStartTime = time.monotonic()
self._changeState(self.STATE_PAUSING)
if self.isSdFileSelected() and local_handling:
@@ -2117,7 +2116,7 @@ class MachineCom:
if line is None:
break
now = monotonic_time()
now = time.monotonic()
if line.strip() != "":
self._consecutive_timeouts = 0
@@ -2477,7 +2476,7 @@ class MachineCom:
):
self._logger.info("Externally triggered heatup detected")
self._heating = True
self._heatupWaitStartTime = monotonic_time()
self._heatupWaitStartTime = time.monotonic()
self._processTemperatures(line)
self._callback.on_comm_temperature_update(
@@ -2901,7 +2900,7 @@ class MachineCom:
### Serial detection
if self._state == self.STATE_DETECT_SERIAL:
if line == "" or monotonic_time() > self._ok_timeout:
if line == "" or time.monotonic() > self._ok_timeout:
self._perform_detection_step()
elif "start" in line or line.startswith("ok"):
self._onConnected()
@@ -2918,7 +2917,7 @@ class MachineCom:
# if it was a wait we probably missed an ok, so let's simulate that now
self._handle_ok()
self._onConnected()
elif monotonic_time() > self._timeout:
elif time.monotonic() > self._timeout:
if try_hello and self._hello_sent < 3:
self._log(
"No answer from the printer within the connection timeout, trying another hello"
@@ -3139,7 +3138,7 @@ class MachineCom:
try:
if self._serial.timeout != timeout:
self._serial.timeout = timeout
self._timeout = self._ok_timeout = monotonic_time() + timeout
self._timeout = self._ok_timeout = time.monotonic() + timeout
except Exception:
self._log(
"Unexpected error while setting timeout {}: {}".format(
@@ -3210,7 +3209,7 @@ class MachineCom:
if self._heating:
if self._heatupWaitStartTime:
self._heatupWaitTimeLost = self._heatupWaitTimeLost + (
monotonic_time() - self._heatupWaitStartTime
time.monotonic() - self._heatupWaitStartTime
)
self._heatupWaitStartTime = None
self._heating = False
@@ -3516,7 +3515,7 @@ class MachineCom:
return max(comm_timeout, temperature_timeout + 1)
def _get_new_communication_timeout(self):
return monotonic_time() + self._get_communication_timeout_interval()
return time.monotonic() + self._get_communication_timeout_interval()
def _send_from_command_queue(self):
# We loop here to make sure that if we do NOT send the first command
@@ -4007,7 +4006,7 @@ class MachineCom:
#
# this it to prevent the log from getting flooded for extremely bad communication issues
if self._log_resends:
now = monotonic_time()
now = time.monotonic()
new_rate_window = (
self._log_resends_rate_start is None
or self._log_resends_rate_start + self._log_resends_rate_frame < now
@@ -4255,7 +4254,7 @@ class MachineCom:
break
# sleep if we are dwelling
now = monotonic_time()
now = time.monotonic()
if (
self._blockWhileDwelling
and self._dwelling_until
@@ -4971,7 +4970,7 @@ class MachineCom:
def _gcode_M109_sent(
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
):
self._heatupWaitStartTime = monotonic_time()
self._heatupWaitStartTime = time.monotonic()
self._long_running_command = True
self._heating = True
self._gcode_M104_sent(cmd, cmd_type, wait=True, support_r=True)
@@ -4979,7 +4978,7 @@ class MachineCom:
def _gcode_M190_sent(
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
):
self._heatupWaitStartTime = monotonic_time()
self._heatupWaitStartTime = time.monotonic()
self._long_running_command = True
self._heating = True
self._gcode_M140_sent(cmd, cmd_type, wait=True, support_r=True)
@@ -4987,7 +4986,7 @@ class MachineCom:
def _gcode_M191_sent(
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
):
self._heatupWaitStartTime = monotonic_time()
self._heatupWaitStartTime = time.monotonic()
self._long_running_command = True
self._heating = True
self._gcode_M141_sent(cmd, cmd_type, wait=True, support_r=True)
@@ -4995,7 +4994,7 @@ class MachineCom:
def _gcode_M116_sent(
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
):
self._heatupWaitStartTime = monotonic_time()
self._heatupWaitStartTime = time.monotonic()
self._long_running_command = True
self._heating = True
@@ -5109,7 +5108,7 @@ class MachineCom:
_timeout = float(s_match.group("value"))
self._timeout = self._get_new_communication_timeout() + _timeout
self._dwelling_until = monotonic_time() + _timeout
self._dwelling_until = time.monotonic() + _timeout
def _emergency_force_send(self, cmd, message, gcode=None, *args, **kwargs):
# only jump the queue with our command if the EMERGENCY_PARSER capability is available
@@ -5344,7 +5343,7 @@ class PrintingFileInformation:
"""
Marks the print job as started and remembers the start time.
"""
self._start_time = monotonic_time()
self._start_time = time.monotonic()
self._done = False
def close(self):
@@ -5511,7 +5510,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
return process_gcode_line(line, offsets=offsets, current_tool=current_tool)
def _report_stats(self):
duration = monotonic_time() - self._start_time
duration = time.monotonic() - self._start_time
self._logger.info("Finished in {:.3f} s.".format(duration))
pass
@@ -5524,7 +5523,7 @@ class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
def start(self):
PrintingGcodeFileInformation.start(self)
self._start_time = monotonic_time()
self._start_time = time.monotonic()
def getLocalFilename(self):
return self._localFilename
@@ -5536,7 +5535,7 @@ class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
return process_gcode_line(line)
def _report_stats(self):
duration = monotonic_time() - self._start_time
duration = time.monotonic() - self._start_time
read_lines = self._read_lines
if duration > 0 and read_lines > 0:
stats = {
+3 -3
View File
@@ -26,13 +26,13 @@ def duration_log(context=None, log=None):
log = logging.getLogger(__name__).debug
import octoprint.util
import time
start = octoprint.util.monotonic_time()
start = time.monotonic()
try:
yield
finally:
end = octoprint.util.monotonic_time()
end = time.monotonic()
duration = end - start
if context: