#10068 Output the package name and build taskID to both console and a file
Merged 3 years ago by mohanboddu. Opened 3 years ago by tdawson.
tdawson/releng buildmeoutput  into  main

file modified
+19 -1
@@ -33,6 +33,24 @@ 

  # Define functions

  

  # This function needs a dry-run like option

+ def buildmeoutput(cmd, action, pkg, env, cwd=workdir):

+     """Simple function to run a command and return 0 for success, 1 for

+        failure.  It also writes the taskID and name to a file and console.

+        cmd is the command and arguments, action is aname for the action (for

+        logging), pkg is the name of the packagebeing operated on, env is the

+        environment dict, and cwd is where the script should be executed from."""

+ 

+     try:

+         output = subprocess.check_output(cmd, env=env, cwd=cwd).decode('utf-8').split()

+         with open(workdir+"/taskID_file", 'a') as task_file:

+             task_file.write('%s %s\n' % (pkg, output[2]))

+         sys.stdout.write('  Successful submission: %s  taskID: %s\n' % (pkg, output[2]))

+     except subprocess.CalledProcessError as e:

+         sys.stderr.write('%s failed %s: %s\n' % (pkg, action, e))

+         return 1

+     return 0

+ 

+ # This function needs a dry-run like option

  def runme(cmd, action, pkg, env, cwd=workdir):

      """Simple function to run a command and return 0 for success, 1 for

         failure.  cmd is a list of the command and arguments, action is a
@@ -176,5 +194,5 @@ 

      # build

      build = [koji_bin, 'build', '--nowait', '--background', '--fail-fast', massrebuild['target'], url]

      print('Building %s' % name)

-     runme(build, 'build', name, enviro, 

+     buildmeoutput(build, 'build', name, enviro,

            cwd=os.path.join(workdir, name))

The current way of checking if a package has failed or not, misses failures due to srpm build failures.
The only way to catch those is by checking taskID's directly.
This patch prints out the package and task id to both console, and a file.
I did some time tests and found that the increase in time was undetectable.

Signed-off-by: Troy Dawson tdawson@redhat.com

Isn't this should be cwd+"/taskID_file"?

This should be pkg instead of name and same as below.

Isn't this should be cwd+"/taskID_file"?

Not if we want them all in the same file. When this function is called, we call it with cwd=os.path.join(workdir, name)

This should be pkg instead of name and same as below.

Good catch. Fixing.

rebased onto 262b242

3 years ago

Isn't this should be cwd+"/taskID_file"?

Not if we want them all in the same file. When this function is called, we call it with cwd=os.path.join(workdir, name)

Yeah, you are right. LGTM and merging away.

Pull-Request has been merged by mohanboddu

3 years ago
Metadata