#852 drop encode_int helper
Merged 5 years ago by mikem. Opened 6 years ago by tkopecek.
tkopecek/koji issue750  into  master

file modified
+4 -6
@@ -3610,8 +3610,6 @@ 

  

  

  def _fix_rpm_row(row):

-     if 'size' in row:

-         row['size'] = koji.encode_int(row['size'])

      if 'extra' in row:

          row['extra'] = parse_json(row['extra'], desc='rpm extra')

      return row
@@ -8899,7 +8897,7 @@ 

              st = os.fstat(fd)

              if not stat.S_ISREG(st.st_mode):

                  raise koji.GenericError("Not a regular file: %s" % fn)

-             data['size'] = koji.encode_int(st.st_size)

+             data['size'] = st.st_size

              data['mtime'] = st.st_mtime

              if verify:

                  sum_cls = get_verify_class(verify)
@@ -8915,7 +8913,7 @@ 

                      length += len(chunk)

                      chksum.update(chunk)

                      chunk = os.read(fd, 8192)

-                 data['sumlength'] = koji.encode_int(length)

+                 data['sumlength'] = length

                  data['hexdigest'] = chksum.hexdigest()

              return data

          finally:
@@ -12703,9 +12701,9 @@ 

          # this will also remove our lock

          os.close(fd)

      ret = {

-         'size': koji.encode_int(size),

+         'size': size,

          'fileverify': verify,

-         'offset': koji.encode_int(offset),

+         'offset': offset,

      }

      if verify:

          # unsigned 32bit - could be too big for xmlrpc

file modified
-10
@@ -453,16 +453,6 @@ 

      ret.update(opts)

      return ret

  

- ## BEGIN kojikamid dup

- 

- def encode_int(n):

-     """If n is too large for a 32bit signed, convert it to a string"""

-     if n <= 2147483647:

-         return n

-     #else

-     return str(n)

- ## END kojikamid dup

- 

  def decode_int(n):

      """If n is not an integer, attempt to convert it"""

      if isinstance(n, six.integer_types):

file modified
+6
@@ -57,6 +57,12 @@ 

  koji.GenericError = GenericError

  koji.BuildError = BuildError

  

+ def encode_int(n):

+     """If n is too large for a 32bit signed, convert it to a string"""

+     if n <= 2147483647:

+         return n

+     #else

+     return str(n)

  

  class WindowsBuild(object):

  

We're already using i8 encoding mechanism, so this function is no more
needed.

Fixes: https://pagure.io/koji/issue/750

From the issue:

The goal of this issue is only to remove the first part (encode_int use on the hub).

Issue #750 is about changing the hub behavior, not actually dropping this function. Of course, if we stop using it, there is little reason to keep it, but we shouldn't actually drop it entirely without deprecating it first.

Other xmlrpc clients may have trouble. For that reason, I'm targeting this at least one release out in the hopes that we can have some conversation and data-gathering first.

I'm not sure we've really done any data gathering here. We should probably have a broader discussion first. I don't know for sure which xmlrpc clients support i8. We do have non-python clients interacting with Koji. Can kojiji handle this?

I've posted a thread on koji-devel about this

Commit 088d500 fixes this pull-request

Pull-Request has been merged by mikem

5 years ago