ddbc41e41f
Making the defrag plugin Python 2+3 compatible. https://bugzilla.suse.com/show_bug.cgi?id=1070322 https://github.com/kdave/btrfsmaintenance/pull/47 OBS-URL: https://build.opensuse.org/request/show/573247 OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsmaintenance?expand=0&rev=33
42 lines
1.2 KiB
Diff
42 lines
1.2 KiB
Diff
Index: btrfsmaintenance-0.4/btrfs-defrag-plugin.py
|
|
===================================================================
|
|
--- btrfsmaintenance-0.4.orig/btrfs-defrag-plugin.py
|
|
+++ btrfsmaintenance-0.4/btrfs-defrag-plugin.py
|
|
@@ -1,4 +1,4 @@
|
|
-#!/usr/bin/python
|
|
+#!/usr/bin/python3
|
|
|
|
# This plugin defragments rpm files after update.
|
|
#
|
|
@@ -17,14 +17,19 @@
|
|
# contiguous space, the bigger the extent is, the worse and the extent
|
|
# size hint is not reached anyway
|
|
|
|
-from sys import stderr
|
|
+import sys
|
|
+if sys.version_info[0] >= 3:
|
|
+ from builtins import str
|
|
+ popen_kwargs = { 'encoding': 'ascii' }
|
|
+else:
|
|
+ popen_kwargs = { }
|
|
from zypp_plugin import Plugin
|
|
import subprocess
|
|
|
|
DEBUG=False
|
|
EXTENT_SIZE=64*1024*1024
|
|
LOGFILE='/tmp/btrfs-defrag-plugin.log'
|
|
-PATH=subprocess.check_output(["rpm", "--eval", "%_dbpath"]).strip()
|
|
+PATH=subprocess.check_output(["rpm", "--eval", "%_dbpath"], **popen_kwargs).strip()
|
|
|
|
def dbg(args):
|
|
if not DEBUG: return
|
|
@@ -34,7 +39,7 @@ def dbg(args):
|
|
f.close()
|
|
|
|
def qx(args):
|
|
- out=subprocess.Popen(args, shell=True, stdout=subprocess.PIPE).stdout
|
|
+ out=subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, **popen_kwargs).stdout
|
|
outstr="".join(out.readlines())
|
|
out.close()
|
|
return outstr
|