Skip to content

Uptime string fails parsing if missing seconds #615

@tyler-8

Description

@tyler-8

Environment

  • Python version: 3.12
  • netutils version: 1.12.0

Expected Behavior

uptime_string_to_seconds("2w1d") would result in an integer of the number of seconds.

Observed Behavior

ValueError: Unable to parse uptime string.

Steps to Reproduce

  1. In a Python shell, from netutils.time import uptime_string_to_seconds
  2. Call function with a string argument that does not contain a seconds value (such as "2w1d")
  3. Observe exception

The closest matching regex parser assumes every uptime string will contain a 'seconds' value, which isn't always true. For example; in the up-time attribute of a NETCONF query to a Cisco IOS-XE device to show BGP neighbors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions