[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 2/2] ! make image-hd: Skripte für Python 3.x angepasst



From: Alexander <alex@xxxxxxxxxx>

Signed-off-by: Alexander Siol <alex@xxxxxxxxxx>
---
 build/scripts/create_partition |   15 ++++++++-------
 build/scripts/get_partition    |    6 +++---
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/build/scripts/create_partition b/build/scripts/create_partition
index feb5574..c0181bc 100755
--- a/build/scripts/create_partition
+++ b/build/scripts/create_partition
@@ -46,26 +46,27 @@ head_count = 16
 # Partitionstabelleneintraege.
 def lba2chs(lba):
     # CHS Berechnen
-    cylinder = lba / (sectors_per_track * head_count)
+    cylinder = int(lba // (sectors_per_track * head_count))
     temp = lba % (head_count * sectors_per_track)
-    head = temp / sectors_per_track;
+    head = temp // sectors_per_track;
     sector = (temp % sectors_per_track) + 1;
 
     # Fuer Partitionstabelle Formatieren
-    a = head
-    b = ((cylinder & 0x300) >> 2) + sector
-    c = cylinder & 0xFF
+    a = int(head)
+    b = int(((cylinder & 0x300) >> 2) + sector)
+    c = int(cylinder & 0xFF)
     return a, b, c
 
 # DWORD in 4 Bytes umrechenen (Little Endian)
 # Zurueckgegeben wird ein Tupel mit den Bytes
 def le_dword(dword):
+    dword = int(dword)
     return (dword >>  0) & 255, (dword >>  8) & 255, (dword >> 16) & 255, (dword >> 24) & 255
 
 
 # Abrrechen wenn kein Argument mit dem Pfad gefunden werden konnte
 if len(sys.argv) <= 1:
-    print 'Bitte Imagepfad angeben'
+    print('Bitte Imagepfad angeben')
     sys.exit(-1)
 
 # Ansonsten wird der Pfad gespeichert
@@ -74,7 +75,7 @@ image_path = sys.argv[1]
 # Image oeffnen
 image_file = open(image_path, mode='r+b')
 if image_file == 0:
-    print 'Image konnte nicht geoeffnet werden.'
+    print('Image konnte nicht geoeffnet werden.')
     sys.exit(-1)
 stat_info = os.lstat(image_path)
 image_size = stat_info[stat.ST_SIZE]
diff --git a/build/scripts/get_partition b/build/scripts/get_partition
index 0f89086..669c55c 100755
--- a/build/scripts/get_partition
+++ b/build/scripts/get_partition
@@ -44,7 +44,7 @@ def le_dword(a, b, c, d):
 
 # Abrrechen wenn kein Argument mit dem Pfad gefunden werden konnte
 if len(sys.argv) <= 1:
-    print 'Bitte Imagepfad angeben'
+    print('Bitte Imagepfad angeben')
     sys.exit(-1)
 
 # Ansonsten wird der Pfad gespeichert
@@ -53,7 +53,7 @@ image_path = sys.argv[1]
 # Image oeffnen
 image_file = open(image_path, mode='rb')
 if image_file == 0:
-    print 'Image konnte nicht geoeffnet werden.'
+    print('Image konnte nicht geoeffnet werden.')
     sys.exit(-1)
 
 # Partitionstabelle vorbereiten und einlesen
@@ -62,7 +62,7 @@ image_file.seek(446)
 part_table.fromfile(image_file, 63)
 
 # Werte anzeigen
-print le_dword(part_table[8], part_table[9], part_table[10], part_table[11]), le_dword(part_table[12], part_table[13], part_table[14], part_table[15])
+print(str(le_dword(part_table[8], part_table[9], part_table[10], part_table[11])) + " " + str(le_dword(part_table[12], part_table[13], part_table[14], part_table[15])))
 
 image_file.close()
 
-- 
1.7.9.3