Last active
May 9, 2018 15:59
-
-
Save samdoran/2c97b5fd074a71617177bb5d86243428 to your computer and use it in GitHub Desktop.
user patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -545,18 +545,21 @@ class User(object): | |
| if self.expires: | |
| current_expires = self.user_password()[1] | |
| - # Convert days since Epoch to seconds since Epoch as struct_time | |
| - total_seconds = int(current_expires) * 86400 | |
| - current_expires = time.gmtime(total_seconds) | |
| + # If the expiration date is positive, self.expires will be a struct_time | |
| + if isinstance(self.expires, time.struct_time): | |
| + # Convert days since Epoch to seconds since Epoch as struct_time | |
| + total_seconds = int(current_expires) * 86400 | |
| + current_expires = time.gmtime(total_seconds) | |
| - # Compare year, month, and day only | |
| - if isinstance(self.expires, (float, int)) or current_expires[:3] != self.expires[:3]: | |
| - cmd.append('-e') | |
| - if isinstance(self.expires, (float, int)) and self.expires < 0: | |
| - cmd.append('') | |
| - else: | |
| + # Compare year, month, and day only | |
| + if current_expires[:3] != self.expires[:3]: | |
| + cmd.append('-e') | |
| cmd.append(time.strftime(self.DATE_FORMAT, self.expires)) | |
| + # If the specified expiration is negative, self.expries will be -1 | |
| + if isinstance(self.expires, (float, int)) and self.expires < 0 and current_expires != self.expires: | |
| + cmd.extend(['-e', '']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment