Fix pylint error relating to logging
authorHugh Brown <hbrown@amplify.com>
Thu, 10 Oct 2013 21:19:05 +0000 (17:19 -0400)
committerHugh Brown <hbrown@amplify.com>
Thu, 10 Oct 2013 22:41:39 +0000 (18:41 -0400)
jenkinsapi/api.py
jenkinsapi/artifact.py
jenkinsapi/build.py
jenkinsapi/fingerprint.py
jenkinsapi/jenkins.py
jenkinsapi/view.py
jenkinsapi/views.py
pylintrc

index d0167bb..ee80b98 100644 (file)
@@ -63,7 +63,7 @@ def get_artifacts(jenkinsurl, jobid=None, build_no=None, proxyhost=None,
     else:
         build = job.get_last_good_build()
     artifacts = build.get_artifact_dict()
-    log.info("Found %i artifacts in '%s'" % (len(artifacts.keys()), build_no))
+    log.info(msg="Found %i artifacts in '%s'" % (len(artifacts.keys()), build_no))
     return artifacts
 
 
@@ -84,7 +84,7 @@ def search_artifacts(jenkinsurl, jobid, artifact_ids=None):
         if set(artifact_ids).issubset(set(artifacts.keys())):
             return dict((a, artifacts[a]) for a in artifact_ids)
         missing_artifacts = set(artifact_ids) - set(artifacts.keys())
-        log.debug("Artifacts %s missing from %s #%i" % (", ".join(missing_artifacts), jobid, build_id))
+        log.debug(msg="Artifacts %s missing from %s #%i" % (", ".join(missing_artifacts), jobid, build_id))
     #noinspection PyUnboundLocalVariable
     raise ArtifactsMissing(missing_artifacts)
 
@@ -116,7 +116,7 @@ def block_until_complete(jenkinsurl, jobs, maxwait=12000, interval=30, raise_on_
         if not still_running:
             return
         str_still_running = ", ".join('"%s"' % str(a) for a in still_running)
-        log.warn("Waiting for jobs %s to complete. Will wait another %is" % (str_still_running, time_left))
+        log.warn(msg="Waiting for jobs %s to complete. Will wait another %is" % (str_still_running, time_left))
         time.sleep(interval)
     if raise_on_timeout:
         #noinspection PyUnboundLocalVariable
@@ -155,7 +155,7 @@ def install_artifacts(artifacts, dirstruct, installdir, basestaticurl):
     for reldir, artifactnames in dirstruct.items():
         destdir = os.path.join(installdir, reldir)
         if not os.path.exists(destdir):
-            log.warn("Making install directory %s" % destdir)
+            log.warn(msg="Making install directory %s" % destdir)
             os.makedirs(destdir)
         else:
             assert os.path.isdir(destdir)
index e4cccab..4ac0acf 100644 (file)
@@ -36,14 +36,14 @@ class Artifact(object):
         :param fspath: full pathname including the filename, str
         :return: filepath
         """
-        log.info("Saving artifact @ %s to %s" % (self.url, fspath))
+        log.info(msg="Saving artifact @ %s to %s" % (self.url, fspath))
         if not fspath.endswith(self.filename):
-            log.warn("Attempt to change the filename of artifact %s on save." % self.filename)
+            log.warn(msg="Attempt to change the filename of artifact %s on save." % self.filename)
         if os.path.exists(fspath):
             if self.build:
                 try:
                     if self._verify_download(fspath):
-                        log.info("Local copy of %s is already up to date." % self.filename)
+                        log.info(msg="Local copy of %s is already up to date." % self.filename)
                         return fspath
                 except ArtifactBroken:
                     log.info("Jenkins artifact could not be identified.")
index 6379cbb..f18427c 100644 (file)
@@ -251,7 +251,7 @@ class Build(JenkinsBase):
         count = 0
         while self.is_running():
             total_wait = delay * count
-            log.info("Waited %is for %s #%s to complete" % (total_wait, self.job.name, self.name))
+            log.info(msg="Waited %is for %s #%s to complete" % (total_wait, self.job.name, self.name))
             sleep(delay)
             count += 1
 
index 22ebeea..7ca13b7 100644 (file)
@@ -64,13 +64,13 @@ class Fingerprint(JenkinsBase):
                 if self._data["original"]["number"] == build:
                     return True
         if self._data["fileName"] != filename:
-            log.info("Filename from jenkins (%s) did not match provided (%s)" % (self._data["fileName"], filename))
+            log.info(msg="Filename from jenkins (%s) did not match provided (%s)" % (self._data["fileName"], filename))
             return False
         for usage_item in self._data["usage"]:
             if usage_item["name"] == job:
                 for range in usage_item["ranges"]["ranges"]:
                     if range["start"] <= build <= range["end"]:
-                        log.info("This artifact was generated by %s between build %i and %i" % (job, range["start"], range["end"]))
+                        log.info(msg="This artifact was generated by %s between build %i and %i" % (job, range["start"], range["end"]))
                         return True
         return False
 
index 877def2..bfd4aa2 100644 (file)
@@ -47,7 +47,7 @@ class Jenkins(JenkinsBase):
     def validate_fingerprint(self, id):
         obj_fingerprint = Fingerprint(self.baseurl, id, jenkins_obj=self)
         obj_fingerprint.validate()
-        log.info("Jenkins says %s is valid" % id)
+        log.info(msg="Jenkins says %s is valid" % id)
 
     # def reload(self):
     #     '''Try and reload the configuration from disk'''
index dd6ae77..ff2f03d 100644 (file)
@@ -88,7 +88,7 @@ class View(JenkinsBase):
         """
         if not job:
             if str_job_name in self.get_job_dict():
-                log.warn('Job %s is already in the view %s' %
+                log.warn(msg='Job %s is already in the view %s' %
                          (str_job_name, self.name))
                 return False
             else:
@@ -99,12 +99,12 @@ class View(JenkinsBase):
                 top_jenkins = self.get_jenkins_obj().get_jenkins_obj_from_url(
                     self.baseurl.split('view/')[0])
                 if not top_jenkins.has_job(str_job_name):
-                    log.error('Job "%s" is not known to Jenkins' % str_job_name)
+                    log.error(msg='Job "%s" is not known to Jenkins' % str_job_name)
                     return False
                 else:
                     job = top_jenkins.get_job(str_job_name)
 
-        log.info('Creating job %s in view %s' % (str_job_name, self.name))
+        log.info(msg='Creating job %s in view %s' % (str_job_name, self.name))
         data = {
             "description": "",
             "statusFilter": "",
@@ -139,7 +139,7 @@ class View(JenkinsBase):
         self.get_jenkins_obj().requester.post_and_confirm_status(
             '%s/configSubmit' % self.baseurl, data=data)
         self.poll()
-        log.debug('Job "%s" has been added to a view "%s"' %
+        log.debug(msg='Job "%s" has been added to a view "%s"' %
                   (job.name, self.name))
         return True
 
index c1c1189..2e6412c 100644 (file)
@@ -96,11 +96,11 @@ class Views(object):
         :param person: Person name (to create personal view), str
         :return: new View obj or None if view was not created
         """
-        log.info('Creating "%s" view "%s"' % (view_type, view_name))
+        log.info(msg='Creating "%s" view "%s"' % (view_type, view_name))
         #url = urlparse.urljoin(self.baseurl, "user/%s/my-views/" % person) if person else self.baseurl
 
         if view_name in self:
-            log.warn('View "%s" already exists' % view_name)
+            log.warn(msg='View "%s" already exists' % view_name)
             return self[view_name]
 
         url = '%s/createView' % self.jenkins.baseurl
index 0298c4e..06664c7 100644 (file)
--- a/pylintrc
+++ b/pylintrc
@@ -119,7 +119,8 @@ argument-rgx=[a-z_][a-z0-9_]{2,40}$
 
 # Regular expression which should only match correct variable names
 # Amplify: Up to 40 characters long
-variable-rgx=[a-z_][a-z0-9_]{2,40}$
+# variable-rgx=[a-z_][a-z0-9_]{2,40}$
+variable-rgx=[A-Za-z_][A-Za-z0-9_]{1,40}$
 
 # Regular expression which should only match correct list comprehension /
 # generator expression variable names