[rygel] examples: Port mx-info to Python 3



commit 2fac7194c7d3a2f8a0c0a6fffd62298a60d5d611
Author: Jens Georg <mail jensge org>
Date:   Thu Jan 11 20:22:33 2018 +0100

    examples: Port mx-info to Python 3

 examples/mx-info |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/examples/mx-info b/examples/mx-info
index beed10d..30efc10 100755
--- a/examples/mx-info
+++ b/examples/mx-info
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # This file is part of Rygel.
 # Copyright (C) 2015 Jens Georg <mail jensge org>
@@ -22,7 +22,7 @@ import os.path
 import time
 from xdg import BaseDirectory
 import sys
-from urllib import pathname2url
+from urllib.request import pathname2url
 import argparse
 
 FILE_QUERY = """
@@ -81,18 +81,16 @@ parser.add_argument ('-u, --unblacklist', action = 'store_true',
 args = parser.parse_args ()
 
 rygel_db = os.path.join (BaseDirectory.xdg_cache_home, "rygel", "media-export.db")
-conn = sqlite3.connect (rygel_db);
+conn = sqlite3.connect (rygel_db)
 
-c = conn.cursor ();
-c.execute ("SELECT version FROM schema_info");
+c = conn.cursor ()
+c.execute ("SELECT version FROM schema_info")
 info = c.fetchone()
-if info[0] < 16:
-    print "Unsupported schema version or not a Rygel cache"
+if int(info[0]) < 16:
+    print("Unsupported schema version or not a Rygel cache")
     sys.exit (1)
 
-has_blacklist = False
-if info[0] >= 17:
-    has_blacklist = True
+has_blacklist = int(info[0]) >= 17
 
 if not has_blacklist and args.unblacklist:
     print ('Database version is too old for blacklists, cannot unblacklist')


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