Skip to content

Commit

Permalink
fix tab and space typo
Browse files Browse the repository at this point in the history
  • Loading branch information
giloser committed May 17, 2024
1 parent e1bd96c commit 987dbfe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ dist
*.*~
*.yaml
dev_utils/NOTES.txt
dev_utils/NOTES.txt
dev_utils/NOTES.txt
octoprint_telegram/__init__.py.bak
octoprint_telegram/telegramCommands.py.bak
96 changes: 49 additions & 47 deletions octoprint_telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,11 +1753,11 @@ def _send_msg(
premethod = self._settings.get(["PreImgMethod"])
self._logger.debug("PreImgMethod {}".format(premethod))
precommand = self._settings.get(["PreImgCommand"])
doneprecommand = False
doneprecommand = False
if premethod == "GCODE":
self._logger.debug("PreImgCommand {}".format(precommand))
self._printer.commands(precommand)
doneprecommand = True
doneprecommand = True
elif premethod == "SYSTEM":
self._logger.debug("PreImgCommand {}".format(precommand))
p = subprocess.Popen(precommand, shell=True)
Expand All @@ -1769,20 +1769,21 @@ def _send_msg(
while p.poll() is None:
time.sleep(0.1)
r = p.returncode
self._logger.debug(
self._logger.debug (
"PreImg system command returned: {}".format(r)
doneprecommand = True
)
doneprecommand = True

if doneprecommand:
precommanddelay = self._settings.get_int(["precommand_delay"])
if precommanddelay != None:
if precommanddelay > 0:
time.sleep(precommanddelay)
if doneprecommand:
precommanddelay = self._settings.get_int(["precommand_delay"])
if precommanddelay != None:
if precommanddelay > 0:
time.sleep(precommanddelay)

except Exception as ex:
self._logger.exception("Exception PreImgMethod: " + str(ex))

self._settings.get_int(["message_at_print_done_delay"])
self._settings.get_int(["message_at_print_done_delay"])
if delay > 0:
time.sleep(delay)
try:
Expand Down Expand Up @@ -1992,10 +1993,10 @@ def _send_msg(
self._logger.debug("multicam_profiles : " + str(curr))
for li in curr:
try:
self._logger.debug("multicam profile: " + str(li))
snapshot_url = li.get("snapshot")
self._logger.debug("multicam snapshot : " + str(snapshot_url))
if(snapshot_url == "" or snapshot_url == "http://" or snapshot_url == "https://" or snapshot_url == None):
self._logger.debug("multicam profile: " + str(li))
snapshot_url = li.get("snapshot")
self._logger.debug("multicam snapshot : " + str(snapshot_url))
if(snapshot_url == "" or snapshot_url == "http://" or snapshot_url == "https://" or snapshot_url == None):
snapshot_url = li.get("URL")
self._logger.debug(
"multicam url : " + str(snapshot_url)
Expand Down Expand Up @@ -2183,10 +2184,10 @@ def _send_msg(
try:
if with_image or with_gif:
#delay
postcommanddelay = self._settings.get_int(["postcommand_delay"])
if postcommanddelay != None:
if postcommanddelay > 0:
time.sleep(postcommanddelay)
postcommanddelay = self._settings.get_int(["postcommand_delay"])
if postcommanddelay != None:
if postcommanddelay > 0:
time.sleep(postcommanddelay)

##find a way to decide if should and what command to light on
postmethod = self._settings.get(["PostImgMethod"])
Expand Down Expand Up @@ -2512,7 +2513,7 @@ def setMyCommands(self, force=False):
}
)
commands.append({"command":"again","description":"Print again the same file"})
commands.append(
commands.append(
{"command": "help", "description": "Shows this help message"}
)
resp = requests.post(
Expand Down Expand Up @@ -2588,9 +2589,10 @@ def take_image(self, snapshot_url=""):
flipH = self._settings.global_get(["webcam", "flipH"])
flipV = self._settings.global_get(["webcam", "flipV"])
rotate = self._settings.global_get(["webcam", "rotate90"])
self._logger.debug(
self._logger.debug (
"Image transformations [H:%s, V:%s, R:%s]", flipH, flipV, rotate
image = Image.open(bytes_reader_class(data))
)
image = Image.open(bytes_reader_class(data))
if data == None:
return None
if flipH or flipV or rotate:
Expand Down Expand Up @@ -2726,17 +2728,17 @@ def create_gif_new(self, chatID, sec=7, multicam_prof=0):
if self.TestProgram(["nice", "--version"]) > 0:
params = ["nice", "-n", "20"]

if(os.name != 'nt'):
self._logger.info("test if cpulimit exist")
if self.TestProgram(["cpulimit", "--help"]) <= 0:
self._logger.info(
"cpulimit don't exist so send a message to install and exit"
)
self.send_msg(
self.gEmo("dizzy face")
+ " Problem creating gif, please check log file, and make sure you have installed cpulimit with following command : `sudo apt-get install cpulimit`",
chatID=chatID,
)
if(os.name != 'nt'):
self._logger.info("test if cpulimit exist")
if self.TestProgram(["cpulimit", "--help"]) <= 0:
self._logger.info(
"cpulimit don't exist so send a message to install and exit"
)
self.send_msg(
self.gEmo("dizzy face")
+ " Problem creating gif, please check log file, and make sure you have installed cpulimit with following command : `sudo apt-get install cpulimit`",
chatID=chatID,
)
return ""

self._logger.info("test if ffmpeg exist")
Expand Down Expand Up @@ -2801,21 +2803,21 @@ def create_gif_new(self, chatID, sec=7, multicam_prof=0):
"Caught an exception trying to get number of cpu : " + str(ex)
)

if(os.name != 'nt'):
self._logger.info(
"limit_cpu="
+ str(limit_cpu)
+ " | used_cpu="
+ str(used_cpu)
+ " | because nb_cpu="
+ str(nb_cpu)
)
params.append("cpulimit")
params.append("-l")
params.append(str(limit_cpu))
params.append("-f")
params.append("-z")
params.append("--")
if(os.name != 'nt'):
self._logger.info(
"limit_cpu="
+ str(limit_cpu)
+ " | used_cpu="
+ str(used_cpu)
+ " | because nb_cpu="
+ str(nb_cpu)
)
params.append("cpulimit")
params.append("-l")
params.append(str(limit_cpu))
params.append("-f")
params.append("-z")
params.append("--")
params.append("ffmpeg")
params.append("-y")
params.append("-threads")
Expand Down

0 comments on commit 987dbfe

Please sign in to comment.