Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37532700
en ru br
Репозитории ALT

Группа :: Система/Основа
Пакет: btier

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: fix-code-style.patch
Скачать


From b60da9118c2460da99411a950b7913c6e0aa74ff Mon Sep 17 00:00:00 2001
From: Andrey Bychkov <mrdrew@altlinux.org>
Date: Tue, 28 Jan 2020 18:13:29 +0300
Subject: [PATCH] fix code style for build on python3
---
 tools/contributed/migrate_blocks_freq.py | 144 +++++++++++------------
 1 file changed, 72 insertions(+), 72 deletions(-)
diff --git a/tools/contributed/migrate_blocks_freq.py b/tools/contributed/migrate_blocks_freq.py
index b2b050a..346c5ad 100755
--- a/tools/contributed/migrate_blocks_freq.py
+++ b/tools/contributed/migrate_blocks_freq.py
@@ -143,7 +143,7 @@ def write_sql(cur,blocknr,blockinfo):
 	atime=int(binfo.pop(0))
 	readcount=int(binfo.pop(0))
 	writecount=int(binfo.pop(0))
-	cur.execute("INSERT INTO meta VALUES(?, ?, ?, ?, ?, ?)", \
+	cur.execute("INSERT INTO meta VALUES(?, ?, ?, ?, ?, ?)",
 		(blocknr,device,offset,atime,readcount,writecount))
 
 def sql_open(con):
@@ -167,16 +167,16 @@ def checkPID():
 		cmd = "ps aux | grep %s | grep -v grep" % (otherPID)
 		migrationRunning = str(os.system(cmd))
 		if len(migrationRunning) < 3:
-   			print "There is already a migration running... exiting!\n"
-   			pFile.close()
-   			exit(RET_OK)
-   		else:
-   			print "Found stale PID - removing it...\n"
-   			pFile.close()
-   			os.system("echo myPID > " + pidFile)
-   			pFile = open(pidFile,"w+")
-   			pFile.write(myPID)
-   			pFile.close()
+			print "There is already a migration running... exiting!\n"
+			pFile.close()
+			exit(RET_OK)
+		else:
+			print "Found stale PID - removing it...\n"
+			pFile.close()
+			os.system("echo myPID > " + pidFile)
+			pFile = open(pidFile,"w+")
+			pFile.write(myPID)
+			pFile.close()
 	else:
 		os.system("echo myPID > " + pidFile)
 		pFile = open(pidFile,"w+")
@@ -184,8 +184,8 @@ def checkPID():
 		pFile.close()
 			
 def print_file(fp):
-    fp.seek(0);
-    print fp.read()
+	fp.seek(0)
+	print fp.read()
 
 def get_ctime():
 	t=datetime.datetime.now()
@@ -229,41 +229,41 @@ def printScreen(vpos,hpos,printText):
 		pass
 
 def savestat(device):
-    try:
-       statinfo=os.stat(device)
-    except:
-       return -1
-    else:
-       return 0
+	try:
+		statinfo=os.stat(device)
+	except:
+		return -1
+	else:
+		return 0
 
 def check_valid_device(device):
-    res=savestat(device)
-    if res != 0:
-       print "Not a valid tier device : %s" % device
-       exit(RET_NODEV)
+	res=savestat(device)
+	if res != 0:
+		print "Not a valid tier device : %s" % device
+		exit(RET_NODEV)
 
 def read_total_blocks():
-    blocks=0
-    try:
-        fp=open("/sys/block/"+basename+"/tier/size_in_blocks","r")
-        blocks=fp.read()
-        fp.close()
-    except:
-        return int(int(blocks)/1)
-    else:
-        return int(int(blocks)/1)
+	blocks=0
+	try:
+		fp=open("/sys/block/"+basename+"/tier/size_in_blocks","r")
+		blocks=fp.read()
+		fp.close()
+	except:
+		return int(int(blocks)/1)
+	else:
+		return int(int(blocks)/1)
 
 def read_maxdev():
-    apipath="/sys/block/"+basename+"/tier/attacheddevices"
-    try:
-       fp=open(apipath,"r")
-       devstr=fp.read()
-       fp.close()
-    except:
-       print "Failed to determine attached devices"
-       exit(RET_MIGERR)
-    else:
-       return int(devstr)
+	apipath="/sys/block/"+basename+"/tier/attacheddevices"
+	try:
+		fp=open(apipath,"r")
+		devstr=fp.read()
+		fp.close()
+	except:
+		print "Failed to determine attached devices"
+		exit(RET_MIGERR)
+	else:
+		return int(devstr)
 
 def get_tier_device_sizes():
 	maxdev = read_maxdev()
@@ -285,38 +285,38 @@ def get_tier_blocks_left():
 	tierBlocksLeft[maxdev-1] = int(tierDeviceSize[maxdev-1]) - tierUsedBlocks[maxdev-1]
 
 def migrate_block(blocknr,newdev):
-    apipath="/sys/block/"+basename+"/tier/migrate_block"
-    try:
-       fp=open(apipath,"w")
-       command=str(blocknr)+"/"+str(newdev)
-       fp.write(command)
-       fp.close()
-    except IOError as e:
-       if e.errno == errno.EAGAIN:
-          return errno.EAGAIN
-       print "Failed to migrate block %d to device %d" % (blocknr, newdev)
-       exit(RET_MIGERR)
-    else:
-       return 0
+	apipath="/sys/block/"+basename+"/tier/migrate_block"
+	try:
+		fp=open(apipath,"w")
+		command=str(blocknr)+"/"+str(newdev)
+		fp.write(command)
+		fp.close()
+	except IOError as e:
+		if e.errno == errno.EAGAIN:
+			return errno.EAGAIN
+		print "Failed to migrate block %d to device %d" % (blocknr, newdev)
+		exit(RET_MIGERR)
+	else:
+		return 0
 
 def move_block(blocknr,newdev):
-    global numMigrateThreads
-    # increase thread counter
-    lock.acquire()
-    numMigrateThreads += 1
-    localThread = numMigrateThreads
-    lock.release()
-
-    while True:
-          res=migrate_block(blocknr, newdev)
-          if res != errno.EAGAIN:
-             break
-          time.sleep (.1)
-
-    lock.acquire()
-    numMigrateThreads -= 1
-    lock.release()
-    return 0
+	global numMigrateThreads
+	# increase thread counter
+	lock.acquire()
+	numMigrateThreads += 1
+	localThread = numMigrateThreads
+	lock.release()
+
+	while True:
+		res=migrate_block(blocknr, newdev)
+		if res != errno.EAGAIN:
+			break
+		time.sleep (.1)
+
+	lock.acquire()
+	numMigrateThreads -= 1
+	lock.release()
+	return 0
 
 def do_migration(blockCount):
 	printText = "Migration starts..."
-- 
2.24.1
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin