summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2024-07-18 18:14:19 +0300
committerIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2024-07-18 17:15:50 +0200
commit21fc2f5b63d8882f8bec43e91b67e273b75abc12 (patch)
tree6f41ab03f134a1ff1661650de8b4ec95530ca889
parent51c4f0a5215da7bb5df60a380f7f588967813b3b (diff)
scripts, test-bugzilla-files: fix issues found by Ruff linter
Change-Id: Ic473fa0ccb8edaff3a303354d9676c6f57be655f Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/170697 Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
-rwxr-xr-xscripts/easyhackers.py1
-rwxr-xr-xscripts/rtf-anonymiser.py3
-rwxr-xr-xscripts/tpconv.py2
-rw-r--r--test-bugzilla-files/analyze_logs.py6
-rw-r--r--test-bugzilla-files/test-bugzilla-files.py25
5 files changed, 16 insertions, 21 deletions
diff --git a/scripts/easyhackers.py b/scripts/easyhackers.py
index b957d33c..17b365b8 100755
--- a/scripts/easyhackers.py
+++ b/scripts/easyhackers.py
@@ -8,7 +8,6 @@
#
import sys
-import re
import sh
from urllib.request import urlopen, URLError
from io import BytesIO
diff --git a/scripts/rtf-anonymiser.py b/scripts/rtf-anonymiser.py
index d7238ff1..df2b718a 100755
--- a/scripts/rtf-anonymiser.py
+++ b/scripts/rtf-anonymiser.py
@@ -6,7 +6,8 @@
#
-import sys, getopt
+import sys
+import getopt
def usage(code):
print("Usage: %s [-i|--inline] input.rtf" % sys.argv[0])
diff --git a/scripts/tpconv.py b/scripts/tpconv.py
index 141db10c..725e9975 100755
--- a/scripts/tpconv.py
+++ b/scripts/tpconv.py
@@ -31,7 +31,7 @@ conv = {
# We know that VirtualDevices use a DPI of 96.
# Could use 'gtk.gdk.screen_get_default().get_resolution()' from pygtk.
-conv['pixel'] = conv['inch'] / int(os.environ.get("DPI", "96"));
+conv['pixel'] = conv['inch'] / int(os.environ.get("DPI", "96"))
def convert(amount, fro, to):
# convert to EMU
diff --git a/test-bugzilla-files/analyze_logs.py b/test-bugzilla-files/analyze_logs.py
index f027dc1f..740092c6 100644
--- a/test-bugzilla-files/analyze_logs.py
+++ b/test-bugzilla-files/analyze_logs.py
@@ -42,7 +42,7 @@ def analyze_odfundifflog(odfundifflog_file, differences):
regex = re.compile("/srv/crashtestdata/.+/(\w*)/")
for line in open(odfundifflog_file):
r = regex.search(line)
- if r == None:
+ if r is None:
continue
format = r.groups()[0]
if format not in differences:
@@ -88,12 +88,12 @@ def import_csv(filename):
def export_csv(filename, data, reader, header=True):
fieldnames = set(data.keys())
- if not reader is None:
+ if reader is not None:
fieldnames.update(reader.fieldnames)
writer = csv.DictWriter(open(filename, "w"), sorted(fieldnames), restval=0)
if header:
writer.writeheader()
- if not reader is None:
+ if reader is not None:
for row in reader:
writer.writerow(row)
writer.writerow(data)
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index 22216137..fdfcaad7 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -27,15 +27,12 @@
import getopt
import os
-import glob
import subprocess
import sys
import time
import uuid
-import datetime
import re
-import signal
import threading
try:
from urllib.parse import quote
@@ -161,7 +158,7 @@ class OfficeConnection:
# return ret
def kill(self):
self.suicided = True
- command = "rm /tmp/OSL_PIPE_" + str(os.getuid()) + "_" + self.pipename;
+ command = "rm /tmp/OSL_PIPE_" + str(os.getuid()) + "_" + self.pipename
print(command)
os.system(command)
command = "kill " + str(self.pro.pid)
@@ -221,7 +218,7 @@ def retryInvoke(connection, test):
connection.postTest()
except KeyboardInterrupt:
raise # Ctrl+C should work
- except:
+ except Exception:
print("retryInvoke: caught exception")
raise Exception("FAILED retryInvoke")
@@ -247,7 +244,6 @@ class EventListener(XDocumentEventListener,unohelper.Base):
def mkPropertyValue(name, value):
return uno.createUnoStruct("com.sun.star.beans.PropertyValue",
name, 0, value, 0)
- de
def getComponent(xDoc):
if not xDoc:
@@ -318,7 +314,7 @@ def loadFromURL(xContext, url, t):
raise # means crashed, handle it later
except pyuno.getClass("com.sun.star.lang.IllegalArgumentException"):
pass # means could not open the file, ignore it
- except:
+ except Exception:
if xDoc:
print("CLOSING")
xDoc.close(True)
@@ -397,7 +393,7 @@ def exportDoc(xDoc, filterName, validationCommand, filename, connection, timer):
pass # means could not open the file, ignore it
except pyuno.getClass("com.sun.star.task.ErrorCodeIOException"):
pass
- except:
+ except Exception:
pass
finally:
if t.is_alive():
@@ -420,7 +416,7 @@ def exportDoc(xDoc, filterName, validationCommand, filename, connection, timer):
try:
os.remove(filePath)
- except:
+ except Exception:
pass
def getODFunDiffCommand():
@@ -481,12 +477,12 @@ class ExportFileTest:
"math" : ["odf"]
}
component = getComponent(self.xDoc)
- if not component in formats:
+ if component not in formats:
return []
return formats[component]
def getValidationCommand(self, filterName):
- if self.enable_validation == False:
+ if not self.enable_validation:
return None
# use libreoffice extension schemas from core repo
@@ -515,7 +511,7 @@ class ExportFileTest:
"Office Open XML Text": "java -jar /home/buildslave/source/bin/officeotron.jar",
"Impress Office Open XML": "java -jar /home/buildslave/source/bin/officeotron.jar"
}
- if not filterName in validationCommand:
+ if filterName not in validationCommand:
return None
return validationCommand[filterName]
@@ -617,7 +613,6 @@ class NormalTimer:
return 180
def runLoadFileTests(opts, files, doExport):
- startTime = datetime.datetime.now()
connection = PersistentConnection(opts)
exportedFiles = []
try:
@@ -691,8 +686,8 @@ if __name__ == "__main__":
Previous state needs to be updated. If you are doing now, please ignore \
this warning." % (filename))
continue
- elif not "Diff finished, number of differences found: 0" in output and \
- not filename in exclude_list:
+ elif "Diff finished, number of differences found: 0" not in output and \
+ filename not in exclude_list:
validLog = open(os.environ["CRASHTESTDATA"] + "/current" + filename + ".log.odfundiff", "w")
validLog.write(output)
validLog.close()