atomic_write: use keyword for mode argument
this will allow us to define atomic_write as keyword-only as soon as py2 compatibility is dropped.
This commit is contained in:
1 parent
c05b6572c5
commit
41fab8a36c
9 files changed
+11
-12
No files matched your search
@@ -242,7 +242,7 @@ class FilebasedGroupManager(GroupManager):
|
||||
data = dict(groups=groups,
|
||||
tracked=[x.key for x in Permissions.all()])
|
||||
|
||||
with atomic_write(self._groupfile, "wb", permissions=0o600, max_permissions=0o666) as f:
|
||||
with atomic_write(self._groupfile, mode="wb", permissions=0o600, max_permissions=0o666) as f:
|
||||
import yaml
|
||||
yaml.safe_dump(data, f, default_flow_style=False, indent=4, allow_unicode=True)
|
||||
self._dirty = False
|
||||
|
||||
@@ -499,7 +499,7 @@ class FilebasedUserManager(UserManager):
|
||||
"roles": user._roles
|
||||
}
|
||||
|
||||
with atomic_write(self._userfile, "wb", permissions=0o600, max_permissions=0o666) as f:
|
||||
with atomic_write(self._userfile, mode="wb", permissions=0o600, max_permissions=0o666) as f:
|
||||
yaml.safe_dump(data, f, default_flow_style=False, indent=4, allow_unicode=True)
|
||||
self._dirty = False
|
||||
self._load()
|
||||
|
||||
@@ -87,7 +87,7 @@ class StreamWrapper(AbstractFileWrapper):
|
||||
"""
|
||||
import shutil
|
||||
|
||||
with atomic_write(path, 'wb') as dest:
|
||||
with atomic_write(path, mode='wb') as dest:
|
||||
with self.stream() as source:
|
||||
shutil.copyfileobj(source, dest)
|
||||
|
||||
|
||||
@@ -474,7 +474,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
|
||||
def _save_profile(self, path, profile, allow_overwrite=True):
|
||||
import yaml
|
||||
with octoprint.util.atomic_write(path, 'wb', max_permissions=0o666) as f:
|
||||
with octoprint.util.atomic_write(path, mode='wb', max_permissions=0o666) as f:
|
||||
yaml.safe_dump(profile, f, default_flow_style=False, indent=2, allow_unicode=True)
|
||||
|
||||
def _convert_to_engine(self, profile_path, printer_profile, pos_x=None, pos_y=None, used_extruders=1):
|
||||
|
||||
@@ -189,7 +189,7 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
|
||||
config["loggers"] = {k: v for k, v in config["loggers"].items() if len(v)}
|
||||
|
||||
# save
|
||||
with octoprint.util.atomic_write(self._get_logging_file(), "wb", max_permissions=0o666) as f:
|
||||
with octoprint.util.atomic_write(self._get_logging_file(), mode="wb", max_permissions=0o666) as f:
|
||||
yaml.safe_dump(config, f, default_flow_style=False, indent=2, allow_unicode=True)
|
||||
|
||||
# set runtime logging levels now
|
||||
|
||||
@@ -817,7 +817,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
try:
|
||||
import json
|
||||
with octoprint.util.atomic_write(self._repository_cache_path, 'wb') as f:
|
||||
with octoprint.util.atomic_write(self._repository_cache_path, mode='wb') as f:
|
||||
json.dump(repo_data, f)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while saving repository data to {}: {}".format(self._repository_cache_path, str(e)))
|
||||
@@ -867,7 +867,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
try:
|
||||
import json
|
||||
with octoprint.util.atomic_write(self._notices_cache_path, "wb") as f:
|
||||
with octoprint.util.atomic_write(self._notices_cache_path, mode="wb") as f:
|
||||
json.dump(notice_data, f)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while saving notices to {}: {}".format(self._notices_cache_path, str(e)))
|
||||
|
||||
@@ -461,7 +461,7 @@ class PrinterProfileManager(object):
|
||||
from octoprint.util import atomic_write
|
||||
import yaml
|
||||
try:
|
||||
with atomic_write(path, 'wb', max_permissions=0o666) as f:
|
||||
with atomic_write(path, mode='wb', max_permissions=0o666) as f:
|
||||
yaml.safe_dump(profile, f, default_flow_style=False, indent=2, allow_unicode=True)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while trying to save profile %s" % profile["id"])
|
||||
|
||||
@@ -893,7 +893,7 @@ class PreemptiveCache(object):
|
||||
|
||||
with self._lock:
|
||||
try:
|
||||
with atomic_write(self.cachefile, 'wb', max_permissions=0o666) as handle:
|
||||
with atomic_write(self.cachefile, mode='wb', max_permissions=0o666) as handle:
|
||||
yaml.safe_dump(data, handle,default_flow_style=False, indent=4, allow_unicode=True)
|
||||
except:
|
||||
self._logger.exception("Error while writing {}".format(self.cachefile))
|
||||
|
||||
@@ -1345,9 +1345,8 @@ class Settings(object):
|
||||
if not self._dirty and not force:
|
||||
return False
|
||||
|
||||
from octoprint.util import atomic_write
|
||||
try:
|
||||
with atomic_write(self._configfile, 'wb', prefix="octoprint-config-", suffix=".yaml", permissions=0o600, max_permissions=0o666) as configFile:
|
||||
with atomic_write(self._configfile, mode='wb', prefix="octoprint-config-", suffix=".yaml", permissions=0o600, max_permissions=0o666) as configFile:
|
||||
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=4, allow_unicode=True)
|
||||
self._dirty = False
|
||||
except:
|
||||
@@ -1768,7 +1767,7 @@ class Settings(object):
|
||||
path, _ = os.path.split(filename)
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
with atomic_write(filename, 'wb', max_permissions=0o666) as f:
|
||||
with atomic_write(filename, mode='wb', max_permissions=0o666) as f:
|
||||
f.write(script)
|
||||
|
||||
def generateApiKey(self):
|
||||
|
||||
Reference in new issue
Block a user