[sysadmin-bin] pylint



commit c3533483171a8fa616be487e746d6eb8ad1d82e6
Author: Andrea Veri <averi redhat com>
Date:   Wed Jul 4 12:21:32 2018 +0200

    pylint

 git/post-receive-mirror-github | 48 +++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/git/post-receive-mirror-github b/git/post-receive-mirror-github
index 361acc8..ef86d5e 100755
--- a/git/post-receive-mirror-github
+++ b/git/post-receive-mirror-github
@@ -44,7 +44,7 @@ ORGANIZATION="GNOME"
 name_maps = {}
 
 class GitHub:
-    def __init__ (self):
+    def __init__(self):
         allowed_paths = ['/var/opt/gitlab/git-data/repositories/GNOME']
         if os.path.dirname(os.getcwd()) not in allowed_paths:
             sys.exit(1)
@@ -55,11 +55,11 @@ class GitHub:
             self.user = config.get('Github', 'user')
             self.pw   = config.get('Github', 'password')
         except ConfigParser.NoSectionError:
-            raise Exception ("~/.gitmirrorrc non existant or missing [Github] section with user and password 
keys")
+            raise Exception("~/.gitmirrorrc non existant or missing [Github] section with user and password 
keys")
         except ConfigParser.NoOptionError:
-            raise Exception ("~/.gitmirrorrc misses user or/and password keys in the [Github] section")
+            raise Exception("~/.gitmirrorrc misses user or/and password keys in the [Github] section")
 
-    def check_if_repo_exists (self, name):
+    def check_if_repo_exists(self, name):
         rq = requests.get('https://api.github.com/repos/'+ORGANIZATION+'/'+name,
                           auth=(self.user, self.pw))
         if rq.status_code != 200:
@@ -67,8 +67,8 @@ class GitHub:
 
         return True
 
-    def create_github_repo (self, name, description, homepage):
-        if self.check_if_repo_exists (name):
+    def create_github_repo(self, name, description, homepage):
+        if self.check_if_repo_exists(name):
             return
         payload = json.dumps({
                              'name': self.normalize_name(name),
@@ -109,7 +109,7 @@ class GitHub:
 
         raise Exception("There was an error attempting to fetch the repo %s in github:\n\nStatus: 
%d\nText:\n%s" % (name, rq.status_code, rq.text))
 
-    def normalize_name (self, name):
+    def normalize_name(self, name):
         if name in name_maps.keys():
             return name_maps[name]
 
@@ -118,15 +118,15 @@ class GitHub:
 
         return name
 
-def get_repo_name ():
-    repo_name = os.getcwd ().split("/")[-1]
+def get_repo_name():
+    repo_name = os.getcwd().split("/")[-1]
     if repo_name == ".git":
-        repo_name = os.getcwd ().split("/")[-2]
+        repo_name = os.getcwd().split("/")[-2]
     elif repo_name.endswith(".git"):
         repo_name = repo_name[0:-4]
     return repo_name
 
-def get_repo_settings (repo_name):
+def get_repo_settings(repo_name):
     nss = {'doap': 'http://usefulinc.com/ns/doap#',
            'rdf':  'http://www.w3.org/1999/02/22-rdf-syntax-ns#'}
 
@@ -140,7 +140,7 @@ def get_repo_settings (repo_name):
 
     resource = '{%s}resource' % nss['rdf']
 
-    name = prj.find ('{%s}name' % nss["doap"])
+    name = prj.find('{%s}name' % nss["doap"])
     desc = prj.find('{%s}shortdesc' % nss["doap"])
     homepage = prj.find('{%s}homepage' % nss["doap"])
 
@@ -154,12 +154,12 @@ def get_repo_settings (repo_name):
              "name":        repo_name.encode('utf-8').decode('utf-8'),
              "description": desc.encode('utf-8').decode('utf-8')}
 
-def main ():
-    gh = GitHub ()
-    repo_name = get_repo_name ()
-    github_name = gh.normalize_name (repo_name)
+def main():
+    gh = GitHub()
+    repo_name = get_repo_name()
+    github_name = gh.normalize_name(repo_name)
     description, homepage = gh.fetch_github_repo(github_name)
-    settings = get_repo_settings (repo_name)
+    settings = get_repo_settings(repo_name)
 
     if repo_name.endswith('.wiki.git'):
         sys.exit(1)
@@ -171,11 +171,11 @@ def main ():
         gh.update_github_repo(github_name, 'homepage', settings["homepage"])
 
     if not gh.check_if_repo_exists(repo_name):
-        gh.create_github_repo (settings["name"], settings["description"], settings["homepage"])
+        gh.create_github_repo(settings["name"], settings["description"], settings["homepage"])
     try:
         command = 'git push --mirror git github com:%s/%s' % (ORGANIZATION, github_name)
-        out = tempfile.NamedTemporaryFile (prefix="github",suffix="std")
-        err = tempfile.NamedTemporaryFile (prefix="github",suffix="err")
+        out = tempfile.NamedTemporaryFile(prefix="github",suffix="std")
+        err = tempfile.NamedTemporaryFile(prefix="github",suffix="err")
         subprocess.check_call(shlex.split(command), stderr=err, stdout=out)
         out.close()
         err.close()
@@ -186,13 +186,13 @@ def main ():
 
 if __name__ == "__main__":
     try:
-        main ()
+        main()
     except Exception as e:
         msg = MIMEText(str(e))
-        msg['Subject'] = "[GITHUB HOOK] ERROR trying to push %s" %  os.getcwd ()
+        msg['Subject'] = "[GITHUB HOOK] ERROR trying to push %s" %  os.getcwd()
         msg['From']    = "noreply gnome org"
         msg['To']      = "gnome-sysadmin gnome org"
         msg['X-GNOME-SERVICE'] = "github-mirror"
         server = smtplib.SMTP("localhost")
-        server.sendmail (msg['From'], msg['To'], msg.as_string())
-        server.quit ()
+        server.sendmail(msg['From'], msg['To'], msg.as_string())
+        server.quit()


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