[game-data-packager] 01/09: Turn install_packages into a plain function

Simon McVittie smcv at debian.org
Thu Oct 1 10:16:49 UTC 2015


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch master
in repository game-data-packager.

commit 66928bfca93774de3c4c6567fcac5e36bdb61cc7
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Oct 1 08:17:23 2015 +0100

    Turn install_packages into a plain function
    
    The steam code was using it as if it was a class method, with self
    (which is unused) set to a list of GameData objects instead of
    a single GameData object.
    
    Moving it into util means non-main modules will be able to use it.
---
 game_data_packager/__init__.py | 21 +++------------------
 game_data_packager/util.py     | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 7c3d8b0..0582bba 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -28,7 +28,6 @@ import logging
 import os
 import random
 import re
-import shlex
 import shutil
 import stat
 import subprocess
@@ -50,6 +49,7 @@ from .util import (MEBIBYTE,
         AGENT,
         TemporaryUmask,
         copy_with_substitutions,
+        install_packages,
         mkdir_p,
         rm_rf,
         human_size,
@@ -2656,7 +2656,7 @@ class GameData(object):
                 print('generated "%s"' % os.path.abspath(deb))
 
         if install_debs:
-            self.install_packages(debs)
+            install_packages(debs)
 
         engines_alt = set((p.engine or self.engine) for p in ready)
         engines_alt.discard(None)
@@ -2962,21 +2962,6 @@ class GameData(object):
 
         return debs
 
-    def install_packages(self, debs):
-        print('using su(1) to obtain root privileges and install the package(s)')
-
-        apt_ver = subprocess.check_output(['dpkg-query', '--show',
-                    '--showformat', '${Version}', 'apt'], universal_newlines=True)
-        if Version(apt_ver.strip()) >= Version('1.1'):
-            cmd = 'apt-get install --install-recommends'
-        else:
-            cmd = 'dpkg -i'
-
-        for deb in debs:
-            cmd = cmd + ' ' + shlex.quote(deb)
-
-        subprocess.call(['su', '-c', cmd])
-
     def locate_steam_icon(self, package):
         id = package.steam.get('id') or self.steam.get('id')
         if not id:
@@ -3329,7 +3314,7 @@ def run_steam_meta_mode(parsed, games):
         raise SystemExit(1)
 
     if install_debs:
-        GameData.install_packages(games, all_debs)
+        install_packages(all_debs)
     if workdir:
         rm_rf(workdir)
 
diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index bab69c5..e561375 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -17,10 +17,14 @@
 # /usr/share/common-licenses/GPL-2.
 
 import os
+import shlex
 import shutil
 import stat
 import subprocess
 import sys
+
+from debian.debian_support import Version
+
 from .version import GAME_PACKAGE_VERSION
 
 KIBIBYTE = 1024
@@ -163,3 +167,20 @@ def ascii_safe(string, force=False):
         string = string.translate(str.maketrans('àäçčéèêëîïíłñ§┏┛',
                                                 'aacceeeeiiiln***'))
     return string
+
+def install_packages(debs):
+    """Install one or more packages (a list of filenames)."""
+
+    print('using su(1) to obtain root privileges and install the package(s)')
+
+    apt_ver = subprocess.check_output(['dpkg-query', '--show',
+                '--showformat', '${Version}', 'apt'], universal_newlines=True)
+    if Version(apt_ver.strip()) >= Version('1.1'):
+        cmd = 'apt-get install --install-recommends'
+    else:
+        cmd = 'dpkg -i'
+
+    for deb in debs:
+        cmd = cmd + ' ' + shlex.quote(deb)
+
+    subprocess.call(['su', '-c', cmd])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list