]> git.agnieray.net Git - galette.git/commitdiff
Python3 compatible
authorJohan Cwiklinski <johan@x-tnd.be>
Thu, 23 Apr 2020 21:02:03 +0000 (23:02 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 23 Apr 2020 21:02:03 +0000 (23:02 +0200)
bin/release

index 56c9efa4f58483a8fcabc292fce0c4170e5ca0b3..3ed163321441ed97951b6428073c656ca483f958 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/python
 
-import os, sys, argparse, re, git, httplib, subprocess
+import os, sys, argparse, re, git, http.client, subprocess
 import urlgrabber.progress, tarfile, shutil, gitdb, time, fnmatch
 from datetime import datetime
 from termcolor import colored
-from urlparse import urlparse
+from urllib.parse import urlparse
 
 galette_dl_repo = 'http://download.tuxfamily.org/galette/'
 local_dl_repo = os.path.join(
@@ -27,7 +27,7 @@ def print_err(msg):
     """
     Display colored error message
     """
-    print colored(msg, 'red', attrs=['bold'])
+    print(colored(msg, 'red', attrs=['bold']))
 
 def get_numeric_version(ver):
     """
@@ -72,7 +72,7 @@ def propose_version():
                 last_major = tag.tag
 
     if verbose:
-        print 'last minor: %s | last major %s' % (last_minor, last_major)
+        print('last minor: %s | last major %s' % (last_minor, last_major))
 
     #no version provided. propose one
     new_minor = None
@@ -86,10 +86,10 @@ def propose_version():
 
     new_major = '.'.join(incr_version(last_major))
 
-    print """Proposed versions:
+    print("""Proposed versions:
     minor: %s
     major: %s
-    """ % (new_minor, new_major)
+    """ % (new_minor, new_major))
 
 def get_latest_version():
     """
@@ -125,7 +125,7 @@ def ask_user_confirm(msg):
     else:
         while True:
             sys.stdout.write(msg)
-            choice = raw_input().lower()
+            choice = input().lower()
             if choice == 'y' or choice == 'yes':
                 return True
             elif choice == 'n' or choice == 'no':
@@ -180,7 +180,7 @@ def _do_build(ver):
         parsed = urlparse(url)
         ascparsed = urlparse(urlasc)
 
-        connection = httplib.HTTPConnection(parsed[1], 80)
+        connection = http.client.HTTPConnection(parsed[1], 80)
         connection.request('HEAD', parsed[2])
         response = connection.getresponse()
         exists = response.status == 200
@@ -191,7 +191,7 @@ def _do_build(ver):
             if exists:
                 local = True
 
-        connection = httplib.HTTPConnection(ascparsed[1], 80)
+        connection = http.client.HTTPConnection(ascparsed[1], 80)
         connection.request('HEAD', ascparsed[2])
         response = connection.getresponse()
         ascexists = response.status == 200
@@ -227,7 +227,7 @@ def _do_build(ver):
         msg += '\n\nYou will *NOT* build another one :)'
         print_err(msg)
     else:
-        print 'Building %s...' % rel_name
+        print('Building %s...' % rel_name)
 
         archive_cmd_pattern = 'git archive --prefix=%s/ %s | bzip2 > %s'
         if commit and extra or nightly:
@@ -251,23 +251,23 @@ def _do_build(ver):
                 typestr = 'Commit'
                 typever = commit
 
-            print 'Release name: %s, %s: %s, Dest: %s' % (
+            print('Release name: %s, %s: %s, Dest: %s' % (
                 rel_name,
                 typestr,
                 typever,
                 galette_archive
-            )
-            print 'Archive command: %s' % (archive_cmd)
+            ))
+            print('Archive command: %s' % (archive_cmd))
 
         if commit and extra:
-            print 'Archiving GIT commit %s' % commit
+            print('Archiving GIT commit %s' % commit)
         else:
-            print 'Archiving GIT tag %s' % ver
+            print('Archiving GIT tag %s' % ver)
 
         p1 = subprocess.Popen(archive_cmd, shell=True)
         p1.communicate()
 
-        print 'Adding vendor libraries'
+        print('Adding vendor libraries')
         add_libs(rel_name, galette_archive)
 
         if sign:
@@ -296,7 +296,7 @@ def do_scp(archive):
         scp_cmd = 'scp -i %s %s* ssh.tuxfamily.org:%s' % (ssh_key, archive, path)
     else:
         scp_cmd = 'scp -r %s* ssh.tuxfamily.org:%s' % (archive, path)
-    print scp_cmd
+    print(scp_cmd)
     p1 = subprocess.Popen(scp_cmd, shell=True)
     p1.communicate()
 
@@ -313,7 +313,7 @@ def add_libs(rel_name, galette_archive):
 
     composer_cmd = 'composer install --no-dev'
     composer_dir = os.path.join(src_dir, rel_name, 'galette')
-    print composer_dir
+    print(composer_dir)
     p1 = subprocess.Popen(composer_cmd, shell=True, cwd=composer_dir)
     p1.wait()
 
@@ -395,7 +395,7 @@ def valid_commit(repo, c):
         repo_commit = repo.commit(c)
 
         commit = repo_commit.hexsha[:10]
-        print colored("""Commit information:
+        print(colored("""Commit information:
         Hash:          %s
         Author:        %s
         Authored date: %s
@@ -408,7 +408,7 @@ def valid_commit(repo, c):
             repo_commit.committer,
             time.strftime(dformat, time.gmtime(repo_commit.committed_date)),
             repo_commit.message
-        ), None, 'on_grey', attrs=['bold'])
+        ), None, 'on_grey', attrs=['bold']))
         return True
     except gitdb.exc.BadObject:
         return False
@@ -471,7 +471,7 @@ def main():
     verbose=args.verbose
 
     if verbose:
-        print args
+        print(args)
 
     galette_repo = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     repo = git.Repo(galette_repo)
@@ -505,7 +505,7 @@ def main():
     elif args.commit and args.version and args.extra:
         if valid_commit(repo, args.commit):
             if verbose:
-                print 'Commit is valid'
+                print('Commit is valid')
             build = True
             buildver = args.version
             extra = args.extra