Last active
April 28, 2017 21:35
-
-
Save butlerx/a7cc82ccb5b40a4e3d02c87c26769a58 to your computer and use it in GitHub Desktop.
useradm pylint
This file contains 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
************* Module rbaccount | |
W:131, 0: XXX Should check this before we rename user in ldap, have a (fixme) | |
W:184, 0: XXX (fixme) | |
W:257, 0: TODO (fixme) | |
W:262, 0: TODO (fixme) | |
E: 84,53: Too many positional arguments for function call (too-many-function-args) | |
R:264, 4: Too many arguments (7/5) (too-many-arguments) | |
R: 30, 0: Too many public methods (22/20) (too-many-public-methods) | |
************* Module rbconfig | |
W:220, 0: XXX: need files for carbon now aswell. (fixme) | |
C: 65, 0: Line too long (129/100) (line-too-long) | |
C: 20, 0: Invalid constant name "dir_rrs" (invalid-name) | |
C: 24, 0: Invalid constant name "maxlen_uname" (invalid-name) | |
C: 25, 0: Invalid constant name "maxlen_group" (invalid-name) | |
C: 29, 0: Invalid constant name "ldap_default_objectClass" (invalid-name) | |
C: 30, 0: Invalid constant name "ldap_default_hosts" (invalid-name) | |
C: 34, 0: Invalid constant name "ldap_uri" (invalid-name) | |
C: 35, 0: Invalid constant name "ldap_root_dn" (invalid-name) | |
C: 36, 0: Invalid constant name "ldap_rootpw_file" (invalid-name) | |
C: 37, 0: Invalid constant name "ldap_tree" (invalid-name) | |
C: 38, 0: Invalid constant name "ldap_accounts_tree" (invalid-name) | |
C: 39, 0: Invalid constant name "ldap_group_tree" (invalid-name) | |
C: 40, 0: Invalid constant name "ldap_reserved_tree" (invalid-name) | |
C: 44, 0: Invalid constant name "ldap_dcu_uri" (invalid-name) | |
C: 45, 0: Invalid constant name "ldap_dcu_tree" (invalid-name) | |
C: 46, 0: Invalid constant name "ldap_dcu_rbdn" (invalid-name) | |
C: 47, 0: Invalid constant name "ldap_dcu_rbpw" (invalid-name) | |
C: 48, 0: Invalid constant name "ldap_dcu_students_tree" (invalid-name) | |
C: 50, 0: Invalid constant name "ldap_dcu_staff_tree" (invalid-name) | |
C: 52, 0: Invalid constant name "ldap_dcu_alumni_tree" (invalid-name) | |
C: 57, 0: Invalid constant name "dns_zones" (invalid-name) | |
C: 65, 0: Invalid constant name "mailman_list_suffixes" (invalid-name) | |
C: 69, 0: Invalid constant name "dir_home" (invalid-name) | |
C: 70, 0: Invalid constant name "dir_webtree" (invalid-name) | |
C: 71, 0: Invalid constant name "dir_signaway_state" (invalid-name) | |
C: 72, 0: Invalid constant name "dir_daft" (invalid-name) | |
C: 73, 0: Invalid constant name "dir_skel" (invalid-name) | |
C: 74, 0: Invalid constant name "dir_mailman" (invalid-name) | |
C: 78, 0: Invalid constant name "file_uidNumber" (invalid-name) | |
C: 79, 0: Invalid constant name "file_pre_sync" (invalid-name) | |
C: 80, 0: Invalid constant name "file_rrslog" (invalid-name) | |
C: 81, 0: Invalid constant name "file_shells" (invalid-name) | |
C: 82, 0: Invalid constant name "file_backup_passwd" (invalid-name) | |
C: 83, 0: Invalid constant name "shell_default" (invalid-name) | |
C: 84, 0: Invalid constant name "shell_expired" (invalid-name) | |
C: 88, 0: Invalid constant name "files_group" (invalid-name) | |
C: 95, 0: Invalid constant name "files_host" (invalid-name) | |
C:102, 0: Invalid constant name "files_alias" (invalid-name) | |
C:108, 0: Invalid constant name "command_setquota" (invalid-name) | |
C:109, 0: Invalid constant name "command_chown" (invalid-name) | |
C:110, 0: Invalid constant name "command_chgrp" (invalid-name) | |
C:111, 0: Invalid constant name "command_cp" (invalid-name) | |
C:112, 0: Invalid constant name "command_sendmail" (invalid-name) | |
C:116, 0: Invalid constant name "usertypes" (invalid-name) | |
C:133, 0: Invalid constant name "usertypes_list" (invalid-name) | |
C:141, 0: Invalid constant name "usertypes_paying" (invalid-name) | |
C:145, 0: Invalid constant name "usertypes_dcu" (invalid-name) | |
C:149, 0: Invalid constant name "convert_usertypes" (invalid-name) | |
C:159, 0: Invalid constant name "convert_extra_groups" (invalid-name) | |
C:170, 0: Invalid constant name "convert_primary_groups" (invalid-name) | |
C:180, 0: Missing function docstring (missing-docstring) | |
************* Module rbopt | |
C: 41, 8: Invalid attribute name "cn" (invalid-name) | |
C: 43, 8: Invalid attribute name "id" (invalid-name) | |
C: 46, 8: Invalid attribute name "yearsPaid" (invalid-name) | |
C: 48, 8: Invalid attribute name "loginShell" (invalid-name) | |
R: 18, 0: Too many instance attributes (25/7) (too-many-instance-attributes) | |
R: 18, 0: Too few public methods (0/2) (too-few-public-methods) | |
************* Module rbuser | |
W: 28, 0: XXX NOT IN LDAP: contains primary (fixme) | |
W: 67, 0: XXX remove usr.override (fixme) | |
W: 79, 0: XXX NOT IN LDAP: contains primary (fixme) | |
W:129, 0: XXX set list attributes to empty list [] or None ?? (fixme) | |
R: 18, 0: Too few public methods (1/2) (too-few-public-methods) | |
************* Module rbuserdb | |
W:147, 0: XXX still needed ? (fixme) | |
W:299, 0: XXX: this overrides committe people (typically back to member) (fixme) | |
W:410, 0: XXX Use old passwd.backup file FTTB. Should use (fixme) | |
W:1045, 0: XXX: is this correct way to disable password? (fixme) | |
C: 1, 0: Too many lines in module (1403/1000) (too-many-lines) | |
C: 48, 4: Invalid argument name "dn" (invalid-name) | |
R: 48, 4: Too many arguments (7/5) (too-many-arguments) | |
E: 72,24: Module 'ldap' has no 'OPT_PROTOCOL_VERSION' member (no-member) | |
E:104,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:109,59: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:112,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:120,63: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:126,63: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:133,60: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:139,60: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:166,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:176,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:194,81: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:213,39: Instance of 'RBUser' has no 'usertype' member (no-member) | |
R:214, 8: Consider using ternary (usr.id if usr.id != None else curusr.id) (consider-using-ternary) | |
E:333,70: Module 'ldap' has no 'SCOPE_SUBTREE' member (no-member) | |
E:349,68: Module 'ldap' has no 'SCOPE_SUBTREE' member (no-member) | |
E:368,67: Module 'ldap' has no 'SCOPE_SUBTREE' member (no-member) | |
W:379, 8: Unreachable code (unreachable) | |
E:379,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:390,59: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:400,59: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:511,56: Module 're' has no 'I' member (no-member) | |
E:664,23: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:670,23: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:677,28: Instance of 'RBUser' has no 'loginShell' member (no-member) | |
E:733,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:753,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:759,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:765,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:771,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:777,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:783,59: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:789,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:795,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:801,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:813,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:819,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:825,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:831,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:843,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
E:853,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
W:868, 8: Unreachable code (unreachable) | |
E:868, 8: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
E:871,15: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
W:877, 8: Unreachable code (unreachable) | |
W:883, 8: Unreachable code (unreachable) | |
W:889, 8: Unreachable code (unreachable) | |
E:889, 8: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
E:892,15: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
W:898, 8: Unreachable code (unreachable) | |
W:904, 8: Unreachable code (unreachable) | |
W:910, 8: Unreachable code (unreachable) | |
E:911, 8: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
E:914,14: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
E:915, 8: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
E:920,19: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
W:933, 8: Unreachable code (unreachable) | |
E:939, 8: Instance of 'RBUserDB' has no 'dbh' member (no-member) | |
E:960,22: Instance of 'RBUser' has no 'usertype' member (no-member) | |
C:963,18: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:963,18: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:963,56: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:964,22: Instance of 'RBUser' has no 'usertype' member (no-member) | |
E:965,22: Instance of 'RBUser' has no 'usertype' member (no-member) | |
E:967,15: Instance of 'RBUser' has no 'newbie' member (no-member) | |
E:968,26: Instance of 'RBUser' has no 'usertype' member (no-member) | |
E:969,26: Instance of 'RBUser' has no 'usertype' member (no-member) | |
R:945, 4: Too many branches (15/12) (too-many-branches) | |
C:1038, 4: Invalid method name "userPassword" (invalid-name) | |
C:1054, 4: Invalid method name "uidNumber_findmax" (invalid-name) | |
E:1060,62: Module 'ldap' has no 'SCOPE_ONELEVEL' member (no-member) | |
C:1071, 4: Invalid method name "uidNumber_getnext" (invalid-name) | |
R:1071, 4: Method could be a function (no-self-use) | |
C:1094, 4: Invalid method name "uidNumber_savenext" (invalid-name) | |
C:1094, 4: Invalid argument name "fd" (invalid-name) | |
C:1094, 4: Invalid argument name "uidNumber" (invalid-name) | |
C:1106, 4: Invalid method name "uidNumber_unlock" (invalid-name) | |
C:1106, 4: Invalid argument name "fd" (invalid-name) | |
R:1106, 4: Method could be a function (no-self-use) | |
E:1176,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1177,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1178,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1179,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1180,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1183,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1185,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1187,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1189,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1191,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1200,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1201,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1202,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1203,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1204,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1207,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1209,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1211,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1213,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1215,24: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1224,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1225,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1226,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1235,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1236,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1237,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1238,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1239,13: Module 'ldap' has no 'MOD_REPLACE' member (no-member) | |
E:1387,12: Instance of 'RBUserDB' has no 'cur' member (no-member) | |
R: 35, 0: Too many public methods (96/20) (too-many-public-methods) | |
************* Module rrs | |
W:132, 0: XXX: Stupid Apache on shrapnel has TZ set to US/Eastern, no idea why! (fixme) | |
W:152, 0: XXX remove usr.override (fixme) | |
W:813, 0: XXX remove usr.override (fixme) | |
C:324, 0: Wrong continued indentation (remove 2 spaces). | |
quoteattr(form.getfirst('updatedby') or '')) | |
| ^ (bad-continuation) | |
C:339, 0: Line too long (107/100) (line-too-long) | |
C:341, 0: Line too long (190/100) (line-too-long) | |
C:361, 0: Line too long (225/100) (line-too-long) | |
C:363, 0: Line too long (123/100) (line-too-long) | |
C:438, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_renew(usr, curusr, override = 1) | |
^ (bad-whitespace) | |
C:576, 0: Line too long (231/100) (line-too-long) | |
C:599, 0: Trailing whitespace (trailing-whitespace) | |
C:613, 0: Trailing whitespace (trailing-whitespace) | |
C:625, 0: Trailing whitespace (trailing-whitespace) | |
C:627, 0: Trailing whitespace (trailing-whitespace) | |
C:634, 0: Trailing whitespace (trailing-whitespace) | |
C:640, 0: Line too long (136/100) (line-too-long) | |
C:648, 0: Line too long (133/100) (line-too-long) | |
C:651, 0: Line too long (135/100) (line-too-long) | |
C:657, 0: Line too long (132/100) (line-too-long) | |
C:660, 0: Line too long (134/100) (line-too-long) | |
C:661, 0: Trailing whitespace (trailing-whitespace) | |
C:672, 0: Line too long (205/100) (line-too-long) | |
C:676, 0: Line too long (295/100) (line-too-long) | |
C:677, 0: Line too long (192/100) (line-too-long) | |
C:689, 0: Trailing whitespace (trailing-whitespace) | |
C:694, 0: Trailing whitespace (trailing-whitespace) | |
C:746, 0: Trailing whitespace (trailing-whitespace) | |
C:758, 0: Trailing whitespace (trailing-whitespace) | |
C:799, 0: Trailing whitespace (trailing-whitespace) | |
C:878, 0: Line too long (135/100) (line-too-long) | |
C:881, 0: Trailing whitespace (trailing-whitespace) | |
C: 33, 0: Invalid constant name "cmds" (invalid-name) | |
C: 48, 0: Invalid constant name "cmds_list" (invalid-name) | |
C: 51, 0: Invalid constant name "cmds_noform" (invalid-name) | |
C: 56, 0: Invalid constant name "cmds_custom" (invalid-name) | |
C: 61, 0: Invalid constant name "fields" (invalid-name) | |
C: 84, 0: Invalid constant name "fields_note" (invalid-name) | |
C: 99, 0: Invalid constant name "fields_yesno" (invalid-name) | |
C:108, 0: Invalid constant name "fields_input" (invalid-name) | |
C:118, 0: Invalid constant name "usr" (invalid-name) | |
C:119, 0: Invalid constant name "opt" (invalid-name) | |
C:120, 0: Invalid constant name "udb" (invalid-name) | |
C:120, 6: Invalid constant name "form" (invalid-name) | |
C:121, 0: Invalid constant name "okay" (invalid-name) | |
C:122, 0: Invalid constant name "start_done" (invalid-name) | |
C:122,13: Invalid constant name "end_done" (invalid-name) | |
C:123, 0: Invalid constant name "error_string" (invalid-name) | |
C:123,15: Invalid constant name "notice_string" (invalid-name) | |
C:123,31: Invalid constant name "okay_string" (invalid-name) | |
C:145, 4: Invalid constant name "form" (invalid-name) | |
W:145, 4: Using the global statement (global-statement) | |
C:164, 4: Invalid constant name "udb" (invalid-name) | |
W:164, 4: Using the global statement (global-statement) | |
E:175,15: Module 'ldap' has no 'LDAPError' member (no-member) | |
W:179,12: Use of eval (eval-used) | |
E:180,16: Module 'ldap' has no 'LDAPError' member (no-member) | |
C:196, 4: Invalid constant name "start_done" (invalid-name) | |
W:196, 4: Using the global statement (global-statement) | |
C:275, 4: Invalid constant name "usr" (invalid-name) | |
W:275, 4: Using the global statement (global-statement) | |
E:348,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:355,19: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:356,65: Instance of 'RBUser' has no 'birthday' member (no-member) | |
R:272, 0: Too many branches (29/12) (too-many-branches) | |
R:272, 0: Too many statements (71/50) (too-many-statements) | |
C:383, 4: Invalid constant name "end_done" (invalid-name) | |
W:383, 4: Using the global statement (global-statement) | |
C:447, 4: Invalid constant name "okay" (invalid-name) | |
C:447, 4: Invalid constant name "okay_string" (invalid-name) | |
W:447, 4: Using the global statement (global-statement) | |
E:472,76: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:474,73: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:474,81: Instance of 'RBUser' has no 'course' member (no-member) | |
E:475,17: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:475,46: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:475,66: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:481, 4: Invalid constant name "okay" (invalid-name) | |
C:481, 4: Invalid constant name "okay_string" (invalid-name) | |
W:481, 4: Using the global statement (global-statement) | |
C:495, 4: Invalid constant name "okay" (invalid-name) | |
C:495, 4: Invalid constant name "okay_string" (invalid-name) | |
W:495, 4: Using the global statement (global-statement) | |
E:522,54: Instance of 'RBUser' has no 'oldusertype' member (no-member) | |
E:526,35: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:526,43: Instance of 'RBUser' has no 'course' member (no-member) | |
E:526,61: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:526,82: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:527,30: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:527,50: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:537, 7: Instance of 'RBUser' has no 'oldusertype' member (no-member) | |
E:550,41: Instance of 'RBUser' has no 'newbie' member (no-member) | |
C:558, 4: Invalid constant name "okay" (invalid-name) | |
C:558, 4: Invalid constant name "okay_string" (invalid-name) | |
W:558, 4: Using the global statement (global-statement) | |
E:576,64: Instance of 'RBUser' has no 'newbie' member (no-member) | |
E:576,120: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:576,128: Instance of 'RBUser' has no 'course' member (no-member) | |
E:576,146: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:576,167: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:576,196: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:576,216: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:581, 4: Invalid constant name "okay" (invalid-name) | |
C:581, 4: Invalid constant name "okay_string" (invalid-name) | |
W:581, 4: Using the global statement (global-statement) | |
E:593,37: Instance of 'RBUser' has no 'newbie' member (no-member) | |
C:598, 4: Invalid constant name "okay" (invalid-name) | |
C:598, 4: Invalid constant name "okay_string" (invalid-name) | |
W:598, 4: Using the global statement (global-statement) | |
C:614, 4: Invalid constant name "okay" (invalid-name) | |
W:614, 4: Using the global statement (global-statement) | |
C:626, 4: Invalid constant name "okay_string" (invalid-name) | |
W:626, 4: Using the global statement (global-statement) | |
W:644, 8: Redefining built-in 'id' (redefined-builtin) | |
C:635, 4: Invalid constant name "okay" (invalid-name) | |
W:635, 4: Using the global statement (global-statement) | |
C:644, 8: Invalid variable name "id" (invalid-name) | |
C:645, 8: Invalid variable name "cn" (invalid-name) | |
W:673,27: Redefining built-in 'id' (redefined-builtin) | |
C:673,27: Invalid variable name "id" (invalid-name) | |
C:673,31: Invalid variable name "cn" (invalid-name) | |
C:691, 8: Invalid variable name "fd" (invalid-name) | |
C:692, 4: Invalid variable name "e" (invalid-name) | |
W:708,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:719,20: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
C:741, 4: Invalid variable name "e" (invalid-name) | |
W:744,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:773,18: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:785,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:797,11: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:800,23: Undefined variable 'rbconfig' (undefined-variable) | |
W:808,16: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:817,13: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:827,19: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:830,27: Undefined variable 'rbconfig' (undefined-variable) | |
W:839,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:849,13: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:859,14: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
C:868, 4: Invalid variable name "e" (invalid-name) | |
W:871,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:884,18: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:884,18: Unused argument 'usr' (unused-argument) | |
W:890,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:905,78: Instance of 'RBUser' has no 'updatedby' member (no-member) | |
C:907, 8: Invalid variable name "fd" (invalid-name) | |
C:927, 4: Invalid constant name "error_string" (invalid-name) | |
W:927, 4: Using the global statement (global-statement) | |
W:132, 0: XXX: Stupid Apache on shrapnel has TZ set to US/Eastern, no idea why! (fixme) | |
W:152, 0: XXX remove usr.override (fixme) | |
W:813, 0: XXX remove usr.override (fixme) | |
C:324, 0: Wrong continued indentation (remove 2 spaces). | |
quoteattr(form.getfirst('updatedby') or '')) | |
| ^ (bad-continuation) | |
C:339, 0: Line too long (107/100) (line-too-long) | |
C:341, 0: Line too long (190/100) (line-too-long) | |
C:361, 0: Line too long (225/100) (line-too-long) | |
C:363, 0: Line too long (123/100) (line-too-long) | |
C:438, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_renew(usr, curusr, override = 1) | |
^ (bad-whitespace) | |
C:576, 0: Line too long (231/100) (line-too-long) | |
C:599, 0: Trailing whitespace (trailing-whitespace) | |
C:613, 0: Trailing whitespace (trailing-whitespace) | |
C:625, 0: Trailing whitespace (trailing-whitespace) | |
C:627, 0: Trailing whitespace (trailing-whitespace) | |
C:634, 0: Trailing whitespace (trailing-whitespace) | |
C:640, 0: Line too long (136/100) (line-too-long) | |
C:648, 0: Line too long (133/100) (line-too-long) | |
C:651, 0: Line too long (135/100) (line-too-long) | |
C:657, 0: Line too long (132/100) (line-too-long) | |
C:660, 0: Line too long (134/100) (line-too-long) | |
C:661, 0: Trailing whitespace (trailing-whitespace) | |
C:672, 0: Line too long (205/100) (line-too-long) | |
C:676, 0: Line too long (295/100) (line-too-long) | |
C:677, 0: Line too long (192/100) (line-too-long) | |
C:689, 0: Trailing whitespace (trailing-whitespace) | |
C:694, 0: Trailing whitespace (trailing-whitespace) | |
C:746, 0: Trailing whitespace (trailing-whitespace) | |
C:758, 0: Trailing whitespace (trailing-whitespace) | |
C:799, 0: Trailing whitespace (trailing-whitespace) | |
C:878, 0: Line too long (135/100) (line-too-long) | |
C:881, 0: Trailing whitespace (trailing-whitespace) | |
C: 33, 0: Invalid constant name "cmds" (invalid-name) | |
C: 48, 0: Invalid constant name "cmds_list" (invalid-name) | |
C: 51, 0: Invalid constant name "cmds_noform" (invalid-name) | |
C: 56, 0: Invalid constant name "cmds_custom" (invalid-name) | |
C: 61, 0: Invalid constant name "fields" (invalid-name) | |
C: 84, 0: Invalid constant name "fields_note" (invalid-name) | |
C: 99, 0: Invalid constant name "fields_yesno" (invalid-name) | |
C:108, 0: Invalid constant name "fields_input" (invalid-name) | |
C:118, 0: Invalid constant name "usr" (invalid-name) | |
C:119, 0: Invalid constant name "opt" (invalid-name) | |
C:120, 0: Invalid constant name "udb" (invalid-name) | |
C:120, 6: Invalid constant name "form" (invalid-name) | |
C:121, 0: Invalid constant name "okay" (invalid-name) | |
C:122, 0: Invalid constant name "start_done" (invalid-name) | |
C:122,13: Invalid constant name "end_done" (invalid-name) | |
C:123, 0: Invalid constant name "error_string" (invalid-name) | |
C:123,15: Invalid constant name "notice_string" (invalid-name) | |
C:123,31: Invalid constant name "okay_string" (invalid-name) | |
C:145, 4: Invalid constant name "form" (invalid-name) | |
W:145, 4: Using the global statement (global-statement) | |
C:164, 4: Invalid constant name "udb" (invalid-name) | |
W:164, 4: Using the global statement (global-statement) | |
E:175,15: Module 'ldap' has no 'LDAPError' member (no-member) | |
W:179,12: Use of eval (eval-used) | |
E:180,16: Module 'ldap' has no 'LDAPError' member (no-member) | |
C:196, 4: Invalid constant name "start_done" (invalid-name) | |
W:196, 4: Using the global statement (global-statement) | |
C:275, 4: Invalid constant name "usr" (invalid-name) | |
W:275, 4: Using the global statement (global-statement) | |
E:348,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:355,19: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:356,65: Instance of 'RBUser' has no 'birthday' member (no-member) | |
R:272, 0: Too many branches (58/12) (too-many-branches) | |
R:272, 0: Too many statements (71/50) (too-many-statements) | |
C:383, 4: Invalid constant name "end_done" (invalid-name) | |
W:383, 4: Using the global statement (global-statement) | |
R:396, 0: Too many branches (24/12) (too-many-branches) | |
C:447, 4: Invalid constant name "okay" (invalid-name) | |
C:447, 4: Invalid constant name "okay_string" (invalid-name) | |
W:447, 4: Using the global statement (global-statement) | |
E:472,76: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:474,73: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:474,81: Instance of 'RBUser' has no 'course' member (no-member) | |
E:475,17: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:475,46: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:475,66: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:481, 4: Invalid constant name "okay" (invalid-name) | |
C:481, 4: Invalid constant name "okay_string" (invalid-name) | |
W:481, 4: Using the global statement (global-statement) | |
C:495, 4: Invalid constant name "okay" (invalid-name) | |
C:495, 4: Invalid constant name "okay_string" (invalid-name) | |
W:495, 4: Using the global statement (global-statement) | |
E:522,54: Instance of 'RBUser' has no 'oldusertype' member (no-member) | |
E:526,35: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:526,43: Instance of 'RBUser' has no 'course' member (no-member) | |
E:526,61: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:526,82: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:527,30: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:527,50: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:537, 7: Instance of 'RBUser' has no 'oldusertype' member (no-member) | |
E:550,41: Instance of 'RBUser' has no 'newbie' member (no-member) | |
C:558, 4: Invalid constant name "okay" (invalid-name) | |
C:558, 4: Invalid constant name "okay_string" (invalid-name) | |
W:558, 4: Using the global statement (global-statement) | |
E:576,64: Instance of 'RBUser' has no 'newbie' member (no-member) | |
E:576,120: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:576,128: Instance of 'RBUser' has no 'course' member (no-member) | |
E:576,146: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:576,167: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:576,196: Instance of 'RBUser' has no 'birthday' member (no-member) | |
E:576,216: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:581, 4: Invalid constant name "okay" (invalid-name) | |
C:581, 4: Invalid constant name "okay_string" (invalid-name) | |
W:581, 4: Using the global statement (global-statement) | |
E:593,37: Instance of 'RBUser' has no 'newbie' member (no-member) | |
C:598, 4: Invalid constant name "okay" (invalid-name) | |
C:598, 4: Invalid constant name "okay_string" (invalid-name) | |
W:598, 4: Using the global statement (global-statement) | |
C:614, 4: Invalid constant name "okay" (invalid-name) | |
W:614, 4: Using the global statement (global-statement) | |
C:626, 4: Invalid constant name "okay_string" (invalid-name) | |
W:626, 4: Using the global statement (global-statement) | |
W:644, 8: Redefining built-in 'id' (redefined-builtin) | |
C:635, 4: Invalid constant name "okay" (invalid-name) | |
W:635, 4: Using the global statement (global-statement) | |
C:644, 8: Invalid variable name "id" (invalid-name) | |
C:645, 8: Invalid variable name "cn" (invalid-name) | |
R:632, 0: Too many branches (14/12) (too-many-branches) | |
W:673,27: Redefining built-in 'id' (redefined-builtin) | |
C:673,27: Invalid variable name "id" (invalid-name) | |
C:673,31: Invalid variable name "cn" (invalid-name) | |
C:691, 8: Invalid variable name "fd" (invalid-name) | |
C:692, 4: Invalid variable name "e" (invalid-name) | |
W:708,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:719,20: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
C:741, 4: Invalid variable name "e" (invalid-name) | |
W:744,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:773,18: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:785,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:797,11: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:800,23: Undefined variable 'rbconfig' (undefined-variable) | |
W:808,16: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:817,13: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:827,19: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:830,27: Undefined variable 'rbconfig' (undefined-variable) | |
W:839,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:849,13: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:859,14: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
C:868, 4: Invalid variable name "e" (invalid-name) | |
W:871,17: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:884,18: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
W:884,18: Unused argument 'usr' (unused-argument) | |
W:890,15: Redefining name 'usr' from outer scope (line 118) (redefined-outer-name) | |
E:905,78: Instance of 'RBUser' has no 'updatedby' member (no-member) | |
C:907, 8: Invalid variable name "fd" (invalid-name) | |
C:927, 4: Invalid constant name "error_string" (invalid-name) | |
W:927, 4: Using the global statement (global-statement) | |
************* Module server | |
C: 9, 0: Invalid class name "server" (invalid-name) | |
C: 10, 0: Invalid class name "handler" (invalid-name) | |
C: 11, 0: Invalid constant name "server_address" (invalid-name) | |
W: 16, 8: Attribute 'cgi_info' defined outside __init__ (attribute-defined-outside-init) | |
C: 21, 0: Invalid constant name "httpd" (invalid-name) | |
************* Module useradm | |
W:414, 0: XXX: check id not already in use (fixme) | |
W:888, 0: XXX: Set override by default ? (fixme) | |
W:1921, 0: XXX (fixme) | |
W:2159, 0: XXX: gross hack to make dizer happy. preloads /etc/shells so we can (fixme) | |
W:2168, 0: XXX: valid_shell should raise an exception? (fixme) | |
C:129, 0: Line too long (142/100) (line-too-long) | |
C:290, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_new(usr, override = 1) | |
^ (bad-whitespace) | |
C:413, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_renew(usr, override = 1) | |
^ (bad-whitespace) | |
C:482, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:522, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:566, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:747, 0: No space allowed around keyword argument assignment | |
get_username(usr, check_user_exists = 0) | |
^ (bad-whitespace) | |
C:762, 0: No space allowed around keyword argument assignment | |
get_username(usr, check_user_exists = 0) | |
^ (bad-whitespace) | |
C:791, 0: No space allowed around keyword argument assignment | |
username = ask('Enter username to search user database', optional = 1) | |
^ (bad-whitespace) | |
C:793, 0: No space allowed around keyword argument assignment | |
opt.id = ask('Enter DCU Id number to search user and DCU databases', optional = 1) | |
^ (bad-whitespace) | |
C:795, 0: No space allowed around keyword argument assignment | |
opt.cn = ask('Enter name to search user and DCU databases', optional = 1) | |
^ (bad-whitespace) | |
C:800, 0: Line too long (132/100) (line-too-long) | |
C:807, 0: Line too long (128/100) (line-too-long) | |
C:810, 0: Line too long (130/100) (line-too-long) | |
C:815, 0: Line too long (127/100) (line-too-long) | |
C:818, 0: Line too long (129/100) (line-too-long) | |
C:828, 0: Line too long (173/100) (line-too-long) | |
C:829, 0: Line too long (154/100) (line-too-long) | |
C:831, 0: Line too long (220/100) (line-too-long) | |
C:975, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory']) | |
^ (bad-whitespace) | |
C:975, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory']) | |
^ (bad-whitespace) | |
C:976, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1002, 0: Line too long (129/100) (line-too-long) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1003, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1018, 0: Line too long (112/100) (line-too-long) | |
C:1020, 0: Line too long (101/100) (line-too-long) | |
C:1052, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1087, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1096, 0: Line too long (103/100) (line-too-long) | |
C:1224, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1238, 0: No space allowed around keyword argument assignment | |
udb.set_shell(RBUser(uid = username, loginShell = rbconfig.shell_expired)) | |
^ (bad-whitespace) | |
C:1238, 0: No space allowed around keyword argument assignment | |
udb.set_shell(RBUser(uid = username, loginShell = rbconfig.shell_expired)) | |
^ (bad-whitespace) | |
C:1248, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1287, 0: Line too long (116/100) (line-too-long) | |
C:1296, 0: Line too long (119/100) (line-too-long) | |
C:1303, 0: Line too long (114/100) (line-too-long) | |
C:1305, 0: Line too long (109/100) (line-too-long) | |
C:1342, 0: Line too long (126/100) (line-too-long) | |
C:1347, 0: Line too long (114/100) (line-too-long) | |
C:1352, 0: Line too long (123/100) (line-too-long) | |
C:1356, 0: Line too long (142/100) (line-too-long) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1450, 0: Line too long (116/100) (line-too-long) | |
C:1470, 0: No space allowed around keyword argument assignment | |
def yesno(prompt, default = None): | |
^ (bad-whitespace) | |
C:1546, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Welcome to Redbrick! - Your Account Details | |
To: %s | |
Reply-To: admin-request@redbrick.dcu.ie | |
""" % usr.altmail) | |
^ | (bad-continuation) | |
C:1564, 0: Exactly one space required after comma | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
^ (bad-whitespace) | |
C:1571, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
------------------------------------------------------------------------------- | |
your Redbrick webpage: https://www.redbrick.dcu.ie/~%s | |
your Redbrick email: %s@redbrick.dcu.ie | |
You can find out more about our services at: | |
https://www.redbrick.dcu.ie/about/welcome | |
""" % (usr.uid, usr.uid)) | |
^ | (bad-continuation) | |
C:1582, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
We recommend that you change your password as soon as you login. | |
Problems with your password or wish to change your username? Contact: | |
admin-request@redbrick.dcu.ie | |
Problems using Redbrick in general or not sure what to do? Contact: | |
helpdesk-request@redbrick.dcu.ie | |
Have fun! | |
- Redbrick Admin Team | |
""") | |
^ | (bad-continuation) | |
C:1603, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Time to renew your Redbrick account! - Note our Bank A/C Details have changed. | |
To: %s@redbrick.dcu.ie | |
""" % usr.uid) | |
^ | (bad-continuation) | |
C:1612, 0: Wrong hanging indentation (add 8 spaces). | |
"""Reply-To: accounts@redbrick.dcu.ie | |
Hey there, | |
It's that time again to renew your Redbrick account! | |
Membership prices, as set by the SLC, are as follows: | |
Members EUR 4 | |
Associates EUR 8 | |
Staff EUR 8 | |
Guests EUR 10 | |
Note: if you have left DCU, you need to apply for associate membership. | |
You can pay in person, by lodging money into our account, electronic bank | |
transfer, or even PayPal! All the details you need are here: | |
https://www.redbrick.dcu.ie/help/joining/ | |
Our bank details are: | |
a/c name: DCU Redbrick Society | |
IBAN: IE59BOFI90675027999600 | |
BIC: BOFIIE2D | |
a/c number: 27999600 | |
sort code: 90 - 67 - 50 | |
Please Note! | |
------------""") | |
^ | (bad-continuation) | |
C:1648, 0: Wrong hanging indentation (add 12 spaces). | |
""" | |
If you do not renew by the 30th October 2016, your account will be disabled. | |
Your account will remain on the system for a grace period of a year - you | |
just won't be able to login. So don't worry, it won't be deleted any time | |
soon! You can renew at any time during the year. | |
""") | |
^ | (bad-continuation) | |
C:1656, 0: Wrong hanging indentation (add 12 spaces). | |
""" | |
If you do not renew within the following month, your account WILL BE | |
DELETED at the start of the new year. This is because you were not | |
recorded as having paid for last year and as such are nearing the end of | |
your one year 'grace' period to renew. Please make sure to renew as soon | |
as possible otherwise please contact us at: accounts@redbrick.dcu.ie. | |
""") | |
^ | (bad-continuation) | |
C:1664, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
If in fact you have renewed and have received this email in error, it is | |
important you let us know. Just reply to this email and tell us how and | |
when you renewed and we'll sort it out. | |
For your information, your current Redbrick account details are: | |
username: %s | |
account type: %s | |
name: %s | |
alternative email: %s | |
""" % (usr.uid, usr.usertype, usr.cn, usr.altmail)) | |
^ | (bad-continuation) | |
C:1678, 0: Exactly one space required after comma | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
^ (bad-whitespace) | |
C:1685, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
If any of the above details are wrong, please correct them when you | |
renew! | |
- Redbrick Admin Team | |
""") | |
^ | (bad-continuation) | |
C:1698, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: %s | |
To: committee@redbrick.dcu.ie | |
%s | |
""" % (subject, body)) | |
^ | (bad-continuation) | |
C:1725, 0: No space allowed around keyword argument assignment | |
def get_username(usr, check_user_exists = 1): | |
^ (bad-whitespace) | |
C:1742, 0: No space allowed around keyword argument assignment | |
tmpusr = RBUser(uid = usr.uid) | |
^ (bad-whitespace) | |
C:1798, 0: Line too long (159/100) (line-too-long) | |
C:1798, 0: No space allowed around keyword argument assignment | |
usr.usertype = ask('Enter usertype', defans, hints = [i for i in rbconfig.usertypes_list if opt.mode != 'renew' or i in rbconfig.usertypes_paying]) | |
^ (bad-whitespace) | |
C:1829, 0: Line too long (140/100) (line-too-long) | |
C:1829, 0: No space allowed around keyword argument assignment | |
usr.usertype = ask('Enter conversion usertype', hints = list(rbconfig.usertypes_list) + list(rbconfig.convert_usertypes.keys())) | |
^ (bad-whitespace) | |
C:1854, 0: Line too long (121/100) (line-too-long) | |
C:1854, 0: No space allowed around keyword argument assignment | |
usr.id = ask('Enter student/staff id', defans, optional = opt.mode == 'update' or usr.usertype == 'committe') | |
^ (bad-whitespace) | |
C:1865, 0: No space allowed around keyword argument assignment | |
def get_name(usr, hints = None): | |
^ (bad-whitespace) | |
C:1878, 0: No space allowed around keyword argument assignment | |
usr.cn = ask("Enter name (or account description)", defans, hints = hints) | |
^ (bad-whitespace) | |
C:1959, 0: Line too long (143/100) (line-too-long) | |
C:1959, 0: No space allowed around keyword argument assignment | |
usr.yearsPaid = ask('Enter number of years paid', defans, optional = opt.mode == 'update' or usr.usertype in ('committe', 'guest')) | |
^ (bad-whitespace) | |
C:1970, 0: No space allowed around keyword argument assignment | |
def get_course(usr, hints = None): | |
^ (bad-whitespace) | |
C:1978, 0: Line too long (126/100) (line-too-long) | |
C:1978, 0: No space allowed around keyword argument assignment | |
usr.course = ask('Enter course', usr.course, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1978, 0: No space allowed around keyword argument assignment | |
usr.course = ask('Enter course', usr.course, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1980, 0: No space allowed around keyword argument assignment | |
def get_year(usr, hints = None): | |
^ (bad-whitespace) | |
C:1988, 0: Line too long (120/100) (line-too-long) | |
C:1988, 0: No space allowed around keyword argument assignment | |
usr.year = ask('Enter year', usr.year, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1988, 0: No space allowed around keyword argument assignment | |
usr.year = ask('Enter year', usr.year, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1990, 0: No space allowed around keyword argument assignment | |
def get_email(usr, hints = None): | |
^ (bad-whitespace) | |
C:2003, 0: No space allowed around keyword argument assignment | |
usr.altmail = ask('Enter email', defans, hints = hints) | |
^ (bad-whitespace) | |
C:2058, 0: No space allowed around keyword argument assignment | |
usr.birthday = ask("Enter birthday as 'YYYY-MM-DD'", defans, optional = 1) | |
^ (bad-whitespace) | |
C:2078, 0: Line too long (199/100) (line-too-long) | |
C:2078, 0: No space allowed around keyword argument assignment | |
usr.disuser_period = ask("If the account is to be automatically re-enabled, enter a valid at(1) timespec,\ne.g: '5pm', '12am + 2 weeks', 'now + 1 month' (see at man page).", optional = 1) | |
^ (bad-whitespace) | |
C:2096, 0: Line too long (149/100) (line-too-long) | |
C:2166, 0: Line too long (105/100) (line-too-long) | |
C:2166, 0: No space allowed around keyword argument assignment | |
usr.loginShell = ask('Enter shell', defans, hints = [defans] + list(udb.valid_shells.keys())) | |
^ (bad-whitespace) | |
C:2178, 0: Line too long (117/100) (line-too-long) | |
C:2185, 0: No space allowed around keyword argument assignment | |
def rberror(e, interactive = 0): | |
^ (bad-whitespace) | |
C:2227, 0: No space allowed around keyword argument assignment | |
def error(e, mesg = None): | |
^ (bad-whitespace) | |
C: 1, 0: Too many lines in module (2247/1000) (too-many-lines) | |
C: 35, 0: Invalid constant name "cmds" (invalid-name) | |
C: 76, 0: Invalid constant name "cmds_single_user" (invalid-name) | |
C: 77, 0: Invalid constant name "cmds_single_account" (invalid-name) | |
C: 78, 0: Invalid constant name "cmds_single_user_info" (invalid-name) | |
C: 79, 0: Invalid constant name "cmds_interactive_batch" (invalid-name) | |
C: 80, 0: Invalid constant name "cmds_batch" (invalid-name) | |
C: 81, 0: Invalid constant name "cmds_batch_info" (invalid-name) | |
C: 83, 0: Invalid constant name "cmds_misc" (invalid-name) | |
C: 87, 0: Invalid constant name "cmds_group_desc" (invalid-name) | |
C: 99, 0: Invalid constant name "cmds_all" (invalid-name) | |
C:103, 0: Invalid constant name "cmds_opts" (invalid-name) | |
C:129, 0: Invalid constant name "input_instructions" (invalid-name) | |
C:133, 0: Invalid constant name "opt" (invalid-name) | |
C:134, 0: Invalid constant name "udb" (invalid-name) | |
C:134, 6: Invalid constant name "acc" (invalid-name) | |
C:135, 0: Invalid constant name "header_mesg" (invalid-name) | |
C:156, 8: Invalid variable name "o" (invalid-name) | |
C:156,11: Invalid variable name "a" (invalid-name) | |
C:208, 4: Invalid constant name "udb" (invalid-name) | |
C:208, 4: Invalid constant name "acc" (invalid-name) | |
W:208, 4: Using the global statement (global-statement) | |
E:213,11: Undefined variable 'ldap' (undefined-variable) | |
W:228, 8: Use of eval (eval-used) | |
E:236,11: Undefined variable 'ldap' (undefined-variable) | |
R:141, 0: Too many branches (30/12) (too-many-branches) | |
R:141, 0: Too many statements (83/50) (too-many-statements) | |
C:245,12: More than one statement on a single line (multiple-statements) | |
C:291, 8: Invalid variable name "e" (invalid-name) | |
C:292,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:306, 7: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:337,21: Undefined variable 'rbconfig' (undefined-variable) | |
E:340,66: Instance of 'RBUser' has no 'cn' member (no-member) | |
R:279, 0: Too many branches (13/12) (too-many-branches) | |
R:279, 0: Too many statements (52/50) (too-many-statements) | |
E:427,23: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:429,25: Instance of 'RBUser' has no 'course' member (no-member) | |
E:430,23: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:447,21: Undefined variable 'rbconfig' (undefined-variable) | |
R:376, 0: Too many branches (18/12) (too-many-branches) | |
R:376, 0: Too many statements (63/50) (too-many-statements) | |
C:485, 8: Invalid variable name "e" (invalid-name) | |
C:486,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:492,19: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:494,21: Instance of 'RBUser' has no 'course' member (no-member) | |
E:495,19: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
C:525, 8: Invalid variable name "e" (invalid-name) | |
C:526,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:569, 8: Invalid variable name "e" (invalid-name) | |
C:570,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:592,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:656,17: Undefined variable 'rbconfig' (undefined-variable) | |
W:696, 4: Unreachable code (unreachable) | |
E:694,10: Undefined variable 'RBFatalError' (undefined-variable) | |
E:706,25: Instance of 'RBUser' has no 'disuser_period' member (no-member) | |
W:713, 4: Unreachable code (unreachable) | |
E:711,10: Undefined variable 'RBFatalError' (undefined-variable) | |
W:785, 4: Unreachable code (unreachable) | |
E:783,10: Undefined variable 'RBFatalError' (undefined-variable) | |
C:788, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:799, 8: Invalid variable name "fd" (invalid-name) | |
C:804, 8: Invalid variable name "fd" (invalid-name) | |
E:822,14: Undefined variable 'RBFatalError' (undefined-variable) | |
C:824, 0: Invalid argument name "fd" (invalid-name) | |
W:830,32: Redefining built-in 'id' (redefined-builtin) | |
E:828,53: Undefined variable 'rbconfig' (undefined-variable) | |
E:828,88: Undefined variable 'rbconfig' (undefined-variable) | |
E:829,46: Undefined variable 'rbconfig' (undefined-variable) | |
E:829,75: Undefined variable 'rbconfig' (undefined-variable) | |
C:830,32: Invalid variable name "id" (invalid-name) | |
E:831,64: Undefined variable 'rbconfig' (undefined-variable) | |
E:831,104: Undefined variable 'rbconfig' (undefined-variable) | |
C:843, 4: Invalid variable name "fd" (invalid-name) | |
R:848, 0: Too many local variables (17/15) (too-many-locals) | |
W:886, 4: Use of exec (exec-used) | |
C:904, 4: Invalid variable name "fd" (invalid-name) | |
C:953,15: Invalid variable name "v" (invalid-name) | |
C:963,15: Invalid variable name "v" (invalid-name) | |
C:964,18: More than one statement on a single line (multiple-statements) | |
E:975,54: Undefined variable 'old_ldap' (undefined-variable) | |
E:980,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:998,25: Undefined variable 'old_ldap' (undefined-variable) | |
E:1002,54: Undefined variable 'old_ldap' (undefined-variable) | |
E:1002,100: Undefined variable 'old_ldap' (undefined-variable) | |
E:1015,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1056,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1057,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:1083,25: Undefined variable 'old_ldap' (undefined-variable) | |
E:1092,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1109,32: Undefined variable 'rbconfig' (undefined-variable) | |
W:898, 4: Unused variable 'user_rename_stages' (unused-variable) | |
W:1081, 8: Unused variable 'action' (unused-variable) | |
R:848, 0: Too many branches (37/12) (too-many-branches) | |
R:848, 0: Too many statements (130/50) (too-many-statements) | |
W:1141, 4: Unreachable code (unreachable) | |
E:1139,10: Undefined variable 'RBFatalError' (undefined-variable) | |
W:1210, 4: Unreachable code (unreachable) | |
E:1207,10: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1238,58: Undefined variable 'rbconfig' (undefined-variable) | |
W:1315,12: Redefining built-in 'dir' (redefined-builtin) | |
C:1262, 4: Invalid variable name "uidNumbers" (invalid-name) | |
E:1263,42: Module 're' has no 'I' member (no-member) | |
E:1275,45: Undefined variable 'rbconfig' (undefined-variable) | |
E:1277,11: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1278,23: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1280,23: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1285,19: Undefined variable 'RBWarningError' (undefined-variable) | |
E:1287,80: Undefined variable 'rbconfig' (undefined-variable) | |
E:1289,11: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1290,25: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1292,57: Undefined variable 'rbconfig' (undefined-variable) | |
E:1292,85: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1294,15: Instance of 'RBUser' has no 'newbie' member (no-member) | |
E:1294,30: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1296,76: Undefined variable 'rbconfig' (undefined-variable) | |
E:1296,104: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1298,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1301,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1303,70: Undefined variable 'rbconfig' (undefined-variable) | |
E:1304,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1305,66: Undefined variable 'rbconfig' (undefined-variable) | |
E:1305,94: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:1307,11: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:1307,11: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1309,62: Undefined variable 'rbconfig' (undefined-variable) | |
C:1311,11: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:1313,56: Undefined variable 'rbconfig' (undefined-variable) | |
E:1315,26: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
E:1315,55: Undefined variable 'rbconfig' (undefined-variable) | |
E:1318,61: Undefined variable 'rbconfig' (undefined-variable) | |
E:1321,50: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1321,65: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1323,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1326,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1329,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1332,37: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1333,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1334,26: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1336,55: Undefined variable 'rbconfig' (undefined-variable) | |
E:1336,83: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1342,71: Undefined variable 'rbconfig' (undefined-variable) | |
E:1352,76: Undefined variable 'rbconfig' (undefined-variable) | |
E:1354,15: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
E:1354,36: Undefined variable 'rbconfig' (undefined-variable) | |
E:1356,81: Undefined variable 'rbconfig' (undefined-variable) | |
E:1356,109: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
C:1366, 8: Invalid variable name "uidNumber" (invalid-name) | |
R:1259, 0: Too many branches (28/12) (too-many-branches) | |
R:1259, 0: Too many statements (81/50) (too-many-statements) | |
C:1378, 0: Invalid function name "create_uidNumber" (invalid-name) | |
C:1381, 4: Invalid variable name "n" (invalid-name) | |
C:1383, 4: Invalid variable name "fd" (invalid-name) | |
E:1383,14: Undefined variable 'rbconfig' (undefined-variable) | |
C:1428, 4: Invalid constant name "input_instructions" (invalid-name) | |
W:1428, 4: Using the global statement (global-statement) | |
C:1433, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1436, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1456,10: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1473, 4: Invalid constant name "input_instructions" (invalid-name) | |
W:1473, 4: Using the global statement (global-statement) | |
C:1478, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1481,20: More than one statement on a single line (multiple-statements) | |
C:1495,31: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1525, 4: Invalid constant name "header_mesg" (invalid-name) | |
W:1525, 4: Using the global statement (global-statement) | |
C:1532, 4: Invalid constant name "header_mesg" (invalid-name) | |
W:1532, 4: Using the global statement (global-statement) | |
C:1544, 4: Invalid variable name "fd" (invalid-name) | |
C:1601, 4: Invalid variable name "fd" (invalid-name) | |
C:1696, 4: Invalid variable name "fd" (invalid-name) | |
R:1709, 4: Unnecessary "else" after "return" (no-else-return) | |
E:1713,37: Undefined variable 'rbconfig' (undefined-variable) | |
C:1715, 0: Invalid argument name "fd" (invalid-name) | |
C:1728, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:1746, 8: Invalid variable name "e" (invalid-name) | |
C:1757, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:1769, 8: Invalid variable name "e" (invalid-name) | |
E:1789,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:1790,43: Undefined variable 'rbconfig' (undefined-variable) | |
E:1791,40: Undefined variable 'rbconfig' (undefined-variable) | |
E:1798,77: Undefined variable 'rbconfig' (undefined-variable) | |
E:1798,132: Undefined variable 'rbconfig' (undefined-variable) | |
C:1804, 8: Invalid variable name "e" (invalid-name) | |
E:1819,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:1820,36: Undefined variable 'rbconfig' (undefined-variable) | |
E:1823,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:1829,73: Undefined variable 'rbconfig' (undefined-variable) | |
E:1829,105: Undefined variable 'rbconfig' (undefined-variable) | |
C:1832, 8: Invalid variable name "e" (invalid-name) | |
E:1841,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:1859, 8: Invalid variable name "e" (invalid-name) | |
C:1881, 8: Invalid variable name "e" (invalid-name) | |
W:1905,22: Unused argument 'usr' (unused-argument) | |
W:1915,18: Unused argument 'usr' (unused-argument) | |
E:1944,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:1953,29: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1964, 8: Invalid variable name "e" (invalid-name) | |
C:2006, 8: Invalid variable name "e" (invalid-name) | |
C:2036, 8: Invalid variable name "e" (invalid-name) | |
E:2045,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:2061, 8: Invalid variable name "e" (invalid-name) | |
C:2070, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:2081, 8: Invalid variable name "e" (invalid-name) | |
E:2090,24: Undefined variable 'rbconfig' (undefined-variable) | |
C:2095,12: Invalid variable name "fd" (invalid-name) | |
E:2102,27: Undefined variable 'RBWarningError' (undefined-variable) | |
C:2111, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2119,58: Undefined variable 'rbconfig' (undefined-variable) | |
C:2122, 8: Invalid variable name "e" (invalid-name) | |
C:2131, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2139,61: Undefined variable 'rbconfig' (undefined-variable) | |
C:2142, 8: Invalid variable name "e" (invalid-name) | |
C:2151, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2170,22: Undefined variable 'RBWarningError' (undefined-variable) | |
C:2171, 8: Invalid variable name "e" (invalid-name) | |
C:2177, 0: Missing function docstring (missing-docstring) | |
E:2179,14: Undefined variable 'RBFatalError' (undefined-variable) | |
C:2185, 0: Invalid argument name "e" (invalid-name) | |
E:2205,25: Undefined variable 'RBWarningError' (undefined-variable) | |
R:2212,12: Unnecessary "else" after "return" (no-else-return) | |
W:2200, 4: Unused variable 'res' (unused-variable) | |
C:2227, 0: Invalid argument name "e" (invalid-name) | |
W:414, 0: XXX: check id not already in use (fixme) | |
W:888, 0: XXX: Set override by default ? (fixme) | |
W:1921, 0: XXX (fixme) | |
W:2159, 0: XXX: gross hack to make dizer happy. preloads /etc/shells so we can (fixme) | |
W:2168, 0: XXX: valid_shell should raise an exception? (fixme) | |
C:129, 0: Line too long (142/100) (line-too-long) | |
C:290, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_new(usr, override = 1) | |
^ (bad-whitespace) | |
C:413, 0: No space allowed around keyword argument assignment | |
udb.get_userinfo_renew(usr, override = 1) | |
^ (bad-whitespace) | |
C:482, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:522, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:566, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(id = usr.id) | |
^ (bad-whitespace) | |
C:747, 0: No space allowed around keyword argument assignment | |
get_username(usr, check_user_exists = 0) | |
^ (bad-whitespace) | |
C:762, 0: No space allowed around keyword argument assignment | |
get_username(usr, check_user_exists = 0) | |
^ (bad-whitespace) | |
C:791, 0: No space allowed around keyword argument assignment | |
username = ask('Enter username to search user database', optional = 1) | |
^ (bad-whitespace) | |
C:793, 0: No space allowed around keyword argument assignment | |
opt.id = ask('Enter DCU Id number to search user and DCU databases', optional = 1) | |
^ (bad-whitespace) | |
C:795, 0: No space allowed around keyword argument assignment | |
opt.cn = ask('Enter name to search user and DCU databases', optional = 1) | |
^ (bad-whitespace) | |
C:800, 0: Line too long (132/100) (line-too-long) | |
C:807, 0: Line too long (128/100) (line-too-long) | |
C:810, 0: Line too long (130/100) (line-too-long) | |
C:815, 0: Line too long (127/100) (line-too-long) | |
C:818, 0: Line too long (129/100) (line-too-long) | |
C:828, 0: Line too long (173/100) (line-too-long) | |
C:829, 0: Line too long (154/100) (line-too-long) | |
C:831, 0: Line too long (220/100) (line-too-long) | |
C:975, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory']) | |
^ (bad-whitespace) | |
C:975, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory']) | |
^ (bad-whitespace) | |
C:976, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1002, 0: Line too long (129/100) (line-too-long) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1002, 0: No space allowed around keyword argument assignment | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
^ (bad-whitespace) | |
C:1003, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1018, 0: Line too long (112/100) (line-too-long) | |
C:1020, 0: Line too long (101/100) (line-too-long) | |
C:1052, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1087, 0: No space allowed around keyword argument assignment | |
newusr = RBUser(uid = newuid) | |
^ (bad-whitespace) | |
C:1096, 0: Line too long (103/100) (line-too-long) | |
C:1224, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1238, 0: No space allowed around keyword argument assignment | |
udb.set_shell(RBUser(uid = username, loginShell = rbconfig.shell_expired)) | |
^ (bad-whitespace) | |
C:1238, 0: No space allowed around keyword argument assignment | |
udb.set_shell(RBUser(uid = username, loginShell = rbconfig.shell_expired)) | |
^ (bad-whitespace) | |
C:1248, 0: No space allowed around keyword argument assignment | |
usr = RBUser(uid = username) | |
^ (bad-whitespace) | |
C:1287, 0: Line too long (116/100) (line-too-long) | |
C:1296, 0: Line too long (119/100) (line-too-long) | |
C:1303, 0: Line too long (114/100) (line-too-long) | |
C:1305, 0: Line too long (109/100) (line-too-long) | |
C:1342, 0: Line too long (126/100) (line-too-long) | |
C:1347, 0: Line too long (114/100) (line-too-long) | |
C:1352, 0: Line too long (123/100) (line-too-long) | |
C:1356, 0: Line too long (142/100) (line-too-long) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1391, 0: No space allowed around keyword argument assignment | |
def ask(prompt, default = None, optional = 0, hints = None): | |
^ (bad-whitespace) | |
C:1450, 0: Line too long (116/100) (line-too-long) | |
C:1470, 0: No space allowed around keyword argument assignment | |
def yesno(prompt, default = None): | |
^ (bad-whitespace) | |
C:1546, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Welcome to Redbrick! - Your Account Details | |
To: %s | |
Reply-To: admin-request@redbrick.dcu.ie | |
""" % usr.altmail) | |
^ | (bad-continuation) | |
C:1564, 0: Exactly one space required after comma | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
^ (bad-whitespace) | |
C:1571, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
------------------------------------------------------------------------------- | |
your Redbrick webpage: https://www.redbrick.dcu.ie/~%s | |
your Redbrick email: %s@redbrick.dcu.ie | |
You can find out more about our services at: | |
https://www.redbrick.dcu.ie/about/welcome | |
""" % (usr.uid, usr.uid)) | |
^ | (bad-continuation) | |
C:1582, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
We recommend that you change your password as soon as you login. | |
Problems with your password or wish to change your username? Contact: | |
admin-request@redbrick.dcu.ie | |
Problems using Redbrick in general or not sure what to do? Contact: | |
helpdesk-request@redbrick.dcu.ie | |
Have fun! | |
- Redbrick Admin Team | |
""") | |
^ | (bad-continuation) | |
C:1603, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Time to renew your Redbrick account! - Note our Bank A/C Details have changed. | |
To: %s@redbrick.dcu.ie | |
""" % usr.uid) | |
^ | (bad-continuation) | |
C:1612, 0: Wrong hanging indentation (add 8 spaces). | |
"""Reply-To: accounts@redbrick.dcu.ie | |
Hey there, | |
It's that time again to renew your Redbrick account! | |
Membership prices, as set by the SLC, are as follows: | |
Members EUR 4 | |
Associates EUR 8 | |
Staff EUR 8 | |
Guests EUR 10 | |
Note: if you have left DCU, you need to apply for associate membership. | |
You can pay in person, by lodging money into our account, electronic bank | |
transfer, or even PayPal! All the details you need are here: | |
https://www.redbrick.dcu.ie/help/joining/ | |
Our bank details are: | |
a/c name: DCU Redbrick Society | |
IBAN: IE59BOFI90675027999600 | |
BIC: BOFIIE2D | |
a/c number: 27999600 | |
sort code: 90 - 67 - 50 | |
Please Note! | |
------------""") | |
^ | (bad-continuation) | |
C:1648, 0: Wrong hanging indentation (add 12 spaces). | |
""" | |
If you do not renew by the 30th October 2016, your account will be disabled. | |
Your account will remain on the system for a grace period of a year - you | |
just won't be able to login. So don't worry, it won't be deleted any time | |
soon! You can renew at any time during the year. | |
""") | |
^ | (bad-continuation) | |
C:1656, 0: Wrong hanging indentation (add 12 spaces). | |
""" | |
If you do not renew within the following month, your account WILL BE | |
DELETED at the start of the new year. This is because you were not | |
recorded as having paid for last year and as such are nearing the end of | |
your one year 'grace' period to renew. Please make sure to renew as soon | |
as possible otherwise please contact us at: accounts@redbrick.dcu.ie. | |
""") | |
^ | (bad-continuation) | |
C:1664, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
If in fact you have renewed and have received this email in error, it is | |
important you let us know. Just reply to this email and tell us how and | |
when you renewed and we'll sort it out. | |
For your information, your current Redbrick account details are: | |
username: %s | |
account type: %s | |
name: %s | |
alternative email: %s | |
""" % (usr.uid, usr.usertype, usr.cn, usr.altmail)) | |
^ | (bad-continuation) | |
C:1678, 0: Exactly one space required after comma | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
^ (bad-whitespace) | |
C:1685, 0: Wrong hanging indentation (add 8 spaces). | |
""" | |
If any of the above details are wrong, please correct them when you | |
renew! | |
- Redbrick Admin Team | |
""") | |
^ | (bad-continuation) | |
C:1698, 0: Wrong hanging indentation (add 8 spaces). | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: %s | |
To: committee@redbrick.dcu.ie | |
%s | |
""" % (subject, body)) | |
^ | (bad-continuation) | |
C:1725, 0: No space allowed around keyword argument assignment | |
def get_username(usr, check_user_exists = 1): | |
^ (bad-whitespace) | |
C:1742, 0: No space allowed around keyword argument assignment | |
tmpusr = RBUser(uid = usr.uid) | |
^ (bad-whitespace) | |
C:1798, 0: Line too long (159/100) (line-too-long) | |
C:1798, 0: No space allowed around keyword argument assignment | |
usr.usertype = ask('Enter usertype', defans, hints = [i for i in rbconfig.usertypes_list if opt.mode != 'renew' or i in rbconfig.usertypes_paying]) | |
^ (bad-whitespace) | |
C:1829, 0: Line too long (140/100) (line-too-long) | |
C:1829, 0: No space allowed around keyword argument assignment | |
usr.usertype = ask('Enter conversion usertype', hints = list(rbconfig.usertypes_list) + list(rbconfig.convert_usertypes.keys())) | |
^ (bad-whitespace) | |
C:1854, 0: Line too long (121/100) (line-too-long) | |
C:1854, 0: No space allowed around keyword argument assignment | |
usr.id = ask('Enter student/staff id', defans, optional = opt.mode == 'update' or usr.usertype == 'committe') | |
^ (bad-whitespace) | |
C:1865, 0: No space allowed around keyword argument assignment | |
def get_name(usr, hints = None): | |
^ (bad-whitespace) | |
C:1878, 0: No space allowed around keyword argument assignment | |
usr.cn = ask("Enter name (or account description)", defans, hints = hints) | |
^ (bad-whitespace) | |
C:1959, 0: Line too long (143/100) (line-too-long) | |
C:1959, 0: No space allowed around keyword argument assignment | |
usr.yearsPaid = ask('Enter number of years paid', defans, optional = opt.mode == 'update' or usr.usertype in ('committe', 'guest')) | |
^ (bad-whitespace) | |
C:1970, 0: No space allowed around keyword argument assignment | |
def get_course(usr, hints = None): | |
^ (bad-whitespace) | |
C:1978, 0: Line too long (126/100) (line-too-long) | |
C:1978, 0: No space allowed around keyword argument assignment | |
usr.course = ask('Enter course', usr.course, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1978, 0: No space allowed around keyword argument assignment | |
usr.course = ask('Enter course', usr.course, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1980, 0: No space allowed around keyword argument assignment | |
def get_year(usr, hints = None): | |
^ (bad-whitespace) | |
C:1988, 0: Line too long (120/100) (line-too-long) | |
C:1988, 0: No space allowed around keyword argument assignment | |
usr.year = ask('Enter year', usr.year, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1988, 0: No space allowed around keyword argument assignment | |
usr.year = ask('Enter year', usr.year, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
^ (bad-whitespace) | |
C:1990, 0: No space allowed around keyword argument assignment | |
def get_email(usr, hints = None): | |
^ (bad-whitespace) | |
C:2003, 0: No space allowed around keyword argument assignment | |
usr.altmail = ask('Enter email', defans, hints = hints) | |
^ (bad-whitespace) | |
C:2058, 0: No space allowed around keyword argument assignment | |
usr.birthday = ask("Enter birthday as 'YYYY-MM-DD'", defans, optional = 1) | |
^ (bad-whitespace) | |
C:2078, 0: Line too long (199/100) (line-too-long) | |
C:2078, 0: No space allowed around keyword argument assignment | |
usr.disuser_period = ask("If the account is to be automatically re-enabled, enter a valid at(1) timespec,\ne.g: '5pm', '12am + 2 weeks', 'now + 1 month' (see at man page).", optional = 1) | |
^ (bad-whitespace) | |
C:2096, 0: Line too long (149/100) (line-too-long) | |
C:2166, 0: Line too long (105/100) (line-too-long) | |
C:2166, 0: No space allowed around keyword argument assignment | |
usr.loginShell = ask('Enter shell', defans, hints = [defans] + list(udb.valid_shells.keys())) | |
^ (bad-whitespace) | |
C:2178, 0: Line too long (117/100) (line-too-long) | |
C:2185, 0: No space allowed around keyword argument assignment | |
def rberror(e, interactive = 0): | |
^ (bad-whitespace) | |
C:2227, 0: No space allowed around keyword argument assignment | |
def error(e, mesg = None): | |
^ (bad-whitespace) | |
C: 1, 0: Too many lines in module (2247/1000) (too-many-lines) | |
C: 35, 0: Invalid constant name "cmds" (invalid-name) | |
C: 76, 0: Invalid constant name "cmds_single_user" (invalid-name) | |
C: 77, 0: Invalid constant name "cmds_single_account" (invalid-name) | |
C: 78, 0: Invalid constant name "cmds_single_user_info" (invalid-name) | |
C: 79, 0: Invalid constant name "cmds_interactive_batch" (invalid-name) | |
C: 80, 0: Invalid constant name "cmds_batch" (invalid-name) | |
C: 81, 0: Invalid constant name "cmds_batch_info" (invalid-name) | |
C: 83, 0: Invalid constant name "cmds_misc" (invalid-name) | |
C: 87, 0: Invalid constant name "cmds_group_desc" (invalid-name) | |
C: 99, 0: Invalid constant name "cmds_all" (invalid-name) | |
C:103, 0: Invalid constant name "cmds_opts" (invalid-name) | |
C:129, 0: Invalid constant name "input_instructions" (invalid-name) | |
C:133, 0: Invalid constant name "opt" (invalid-name) | |
C:134, 0: Invalid constant name "udb" (invalid-name) | |
C:134, 6: Invalid constant name "acc" (invalid-name) | |
C:135, 0: Invalid constant name "header_mesg" (invalid-name) | |
C:156, 8: Invalid variable name "o" (invalid-name) | |
C:156,11: Invalid variable name "a" (invalid-name) | |
C:208, 4: Invalid constant name "udb" (invalid-name) | |
C:208, 4: Invalid constant name "acc" (invalid-name) | |
W:208, 4: Using the global statement (global-statement) | |
E:213,11: Undefined variable 'ldap' (undefined-variable) | |
W:228, 8: Use of eval (eval-used) | |
E:236,11: Undefined variable 'ldap' (undefined-variable) | |
R:141, 0: Too many branches (60/12) (too-many-branches) | |
R:141, 0: Too many statements (83/50) (too-many-statements) | |
C:245,12: More than one statement on a single line (multiple-statements) | |
R:247, 0: Too many branches (18/12) (too-many-branches) | |
C:291, 8: Invalid variable name "e" (invalid-name) | |
C:292,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:306, 7: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:337,21: Undefined variable 'rbconfig' (undefined-variable) | |
E:340,66: Instance of 'RBUser' has no 'cn' member (no-member) | |
R:279, 0: Too many branches (26/12) (too-many-branches) | |
R:279, 0: Too many statements (52/50) (too-many-statements) | |
E:427,23: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:429,25: Instance of 'RBUser' has no 'course' member (no-member) | |
E:430,23: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
E:447,21: Undefined variable 'rbconfig' (undefined-variable) | |
R:376, 0: Too many branches (36/12) (too-many-branches) | |
R:376, 0: Too many statements (63/50) (too-many-statements) | |
C:485, 8: Invalid variable name "e" (invalid-name) | |
C:486,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:492,19: Instance of 'RBUser' has no 'cn' member (no-member) | |
E:494,21: Instance of 'RBUser' has no 'course' member (no-member) | |
E:495,19: Instance of 'RBUser' has no 'year' member; maybe 'byear'? (no-member) | |
C:525, 8: Invalid variable name "e" (invalid-name) | |
C:526,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:569, 8: Invalid variable name "e" (invalid-name) | |
C:570,30: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:592,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:656,17: Undefined variable 'rbconfig' (undefined-variable) | |
W:696, 4: Unreachable code (unreachable) | |
E:694,10: Undefined variable 'RBFatalError' (undefined-variable) | |
E:706,25: Instance of 'RBUser' has no 'disuser_period' member (no-member) | |
W:713, 4: Unreachable code (unreachable) | |
E:711,10: Undefined variable 'RBFatalError' (undefined-variable) | |
W:785, 4: Unreachable code (unreachable) | |
E:783,10: Undefined variable 'RBFatalError' (undefined-variable) | |
C:788, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:799, 8: Invalid variable name "fd" (invalid-name) | |
C:804, 8: Invalid variable name "fd" (invalid-name) | |
E:822,14: Undefined variable 'RBFatalError' (undefined-variable) | |
R:780, 0: Too many branches (22/12) (too-many-branches) | |
C:824, 0: Invalid argument name "fd" (invalid-name) | |
W:830,32: Redefining built-in 'id' (redefined-builtin) | |
E:828,53: Undefined variable 'rbconfig' (undefined-variable) | |
E:828,88: Undefined variable 'rbconfig' (undefined-variable) | |
E:829,46: Undefined variable 'rbconfig' (undefined-variable) | |
E:829,75: Undefined variable 'rbconfig' (undefined-variable) | |
C:830,32: Invalid variable name "id" (invalid-name) | |
E:831,64: Undefined variable 'rbconfig' (undefined-variable) | |
E:831,104: Undefined variable 'rbconfig' (undefined-variable) | |
C:843, 4: Invalid variable name "fd" (invalid-name) | |
R:848, 0: Too many local variables (17/15) (too-many-locals) | |
W:886, 4: Use of exec (exec-used) | |
C:904, 4: Invalid variable name "fd" (invalid-name) | |
C:953,15: Invalid variable name "v" (invalid-name) | |
C:963,15: Invalid variable name "v" (invalid-name) | |
C:964,18: More than one statement on a single line (multiple-statements) | |
E:975,54: Undefined variable 'old_ldap' (undefined-variable) | |
E:980,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:998,25: Undefined variable 'old_ldap' (undefined-variable) | |
E:1002,54: Undefined variable 'old_ldap' (undefined-variable) | |
E:1002,100: Undefined variable 'old_ldap' (undefined-variable) | |
E:1015,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1056,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1057,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:1083,25: Undefined variable 'old_ldap' (undefined-variable) | |
E:1092,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1109,32: Undefined variable 'rbconfig' (undefined-variable) | |
W:898, 4: Unused variable 'user_rename_stages' (unused-variable) | |
W:1081, 8: Unused variable 'action' (unused-variable) | |
R:848, 0: Too many branches (74/12) (too-many-branches) | |
R:848, 0: Too many statements (130/50) (too-many-statements) | |
W:1141, 4: Unreachable code (unreachable) | |
E:1139,10: Undefined variable 'RBFatalError' (undefined-variable) | |
W:1210, 4: Unreachable code (unreachable) | |
E:1207,10: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1238,58: Undefined variable 'rbconfig' (undefined-variable) | |
W:1315,12: Redefining built-in 'dir' (redefined-builtin) | |
C:1262, 4: Invalid variable name "uidNumbers" (invalid-name) | |
E:1263,42: Module 're' has no 'I' member (no-member) | |
E:1275,45: Undefined variable 'rbconfig' (undefined-variable) | |
E:1277,11: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1278,23: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1280,23: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1285,19: Undefined variable 'RBWarningError' (undefined-variable) | |
E:1287,80: Undefined variable 'rbconfig' (undefined-variable) | |
E:1289,11: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1290,25: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1292,57: Undefined variable 'rbconfig' (undefined-variable) | |
E:1292,85: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1294,15: Instance of 'RBUser' has no 'newbie' member (no-member) | |
E:1294,30: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1296,76: Undefined variable 'rbconfig' (undefined-variable) | |
E:1296,104: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1298,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1301,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1303,70: Undefined variable 'rbconfig' (undefined-variable) | |
E:1304,15: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1305,66: Undefined variable 'rbconfig' (undefined-variable) | |
E:1305,94: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
C:1307,11: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:1307,11: Instance of 'RBUser' has no 'yearsPaid' member (no-member) | |
E:1309,62: Undefined variable 'rbconfig' (undefined-variable) | |
C:1311,11: Comparison to None should be 'expr is None' (singleton-comparison) | |
E:1313,56: Undefined variable 'rbconfig' (undefined-variable) | |
E:1315,26: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
E:1315,55: Undefined variable 'rbconfig' (undefined-variable) | |
E:1318,61: Undefined variable 'rbconfig' (undefined-variable) | |
E:1321,50: Instance of 'RBUser' has no 'uidNumber' member (no-member) | |
E:1321,65: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1323,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1326,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1329,60: Undefined variable 'rbconfig' (undefined-variable) | |
E:1332,37: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1333,15: Undefined variable 'RBFatalError' (undefined-variable) | |
E:1334,26: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1336,55: Undefined variable 'rbconfig' (undefined-variable) | |
E:1336,83: Instance of 'RBUser' has no 'gidNumber' member (no-member) | |
E:1342,71: Undefined variable 'rbconfig' (undefined-variable) | |
E:1352,76: Undefined variable 'rbconfig' (undefined-variable) | |
E:1354,15: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
E:1354,36: Undefined variable 'rbconfig' (undefined-variable) | |
E:1356,81: Undefined variable 'rbconfig' (undefined-variable) | |
E:1356,109: Instance of 'RBUser' has no 'homeDirectory' member (no-member) | |
C:1366, 8: Invalid variable name "uidNumber" (invalid-name) | |
R:1259, 0: Too many branches (56/12) (too-many-branches) | |
R:1259, 0: Too many statements (81/50) (too-many-statements) | |
C:1378, 0: Invalid function name "create_uidNumber" (invalid-name) | |
C:1381, 4: Invalid variable name "n" (invalid-name) | |
C:1383, 4: Invalid variable name "fd" (invalid-name) | |
E:1383,14: Undefined variable 'rbconfig' (undefined-variable) | |
C:1428, 4: Invalid constant name "input_instructions" (invalid-name) | |
W:1428, 4: Using the global statement (global-statement) | |
C:1433, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1436, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1456,10: Comparison to None should be 'expr is None' (singleton-comparison) | |
R:1391, 0: Too many branches (24/12) (too-many-branches) | |
C:1473, 4: Invalid constant name "input_instructions" (invalid-name) | |
W:1473, 4: Using the global statement (global-statement) | |
C:1478, 7: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1481,20: More than one statement on a single line (multiple-statements) | |
C:1495,31: Comparison to None should be 'expr is None' (singleton-comparison) | |
R:1470, 0: Too many branches (22/12) (too-many-branches) | |
C:1525, 4: Invalid constant name "header_mesg" (invalid-name) | |
W:1525, 4: Using the global statement (global-statement) | |
C:1532, 4: Invalid constant name "header_mesg" (invalid-name) | |
W:1532, 4: Using the global statement (global-statement) | |
C:1544, 4: Invalid variable name "fd" (invalid-name) | |
C:1601, 4: Invalid variable name "fd" (invalid-name) | |
C:1696, 4: Invalid variable name "fd" (invalid-name) | |
R:1709, 4: Unnecessary "else" after "return" (no-else-return) | |
E:1713,37: Undefined variable 'rbconfig' (undefined-variable) | |
C:1715, 0: Invalid argument name "fd" (invalid-name) | |
C:1728, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:1746, 8: Invalid variable name "e" (invalid-name) | |
R:1725, 0: Too many branches (18/12) (too-many-branches) | |
C:1757, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:1769, 8: Invalid variable name "e" (invalid-name) | |
R:1754, 0: Too many branches (16/12) (too-many-branches) | |
E:1789,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:1790,43: Undefined variable 'rbconfig' (undefined-variable) | |
E:1791,40: Undefined variable 'rbconfig' (undefined-variable) | |
E:1798,77: Undefined variable 'rbconfig' (undefined-variable) | |
E:1798,132: Undefined variable 'rbconfig' (undefined-variable) | |
C:1804, 8: Invalid variable name "e" (invalid-name) | |
R:1778, 0: Too many branches (22/12) (too-many-branches) | |
E:1819,17: Undefined variable 'rbconfig' (undefined-variable) | |
E:1820,36: Undefined variable 'rbconfig' (undefined-variable) | |
E:1823,25: Undefined variable 'rbconfig' (undefined-variable) | |
E:1829,73: Undefined variable 'rbconfig' (undefined-variable) | |
E:1829,105: Undefined variable 'rbconfig' (undefined-variable) | |
C:1832, 8: Invalid variable name "e" (invalid-name) | |
R:1810, 0: Too many branches (18/12) (too-many-branches) | |
E:1841,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:1859, 8: Invalid variable name "e" (invalid-name) | |
R:1838, 0: Too many branches (18/12) (too-many-branches) | |
C:1881, 8: Invalid variable name "e" (invalid-name) | |
R:1865, 0: Too many branches (14/12) (too-many-branches) | |
W:1905,22: Unused argument 'usr' (unused-argument) | |
W:1915,18: Unused argument 'usr' (unused-argument) | |
E:1944,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:1953,29: Comparison to None should be 'expr is None' (singleton-comparison) | |
C:1964, 8: Invalid variable name "e" (invalid-name) | |
R:1941, 0: Too many branches (20/12) (too-many-branches) | |
C:2006, 8: Invalid variable name "e" (invalid-name) | |
R:1990, 0: Too many branches (14/12) (too-many-branches) | |
C:2036, 8: Invalid variable name "e" (invalid-name) | |
R:2012, 0: Too many branches (14/12) (too-many-branches) | |
E:2045,27: Undefined variable 'rbconfig' (undefined-variable) | |
C:2061, 8: Invalid variable name "e" (invalid-name) | |
R:2042, 0: Too many branches (16/12) (too-many-branches) | |
C:2070, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
C:2081, 8: Invalid variable name "e" (invalid-name) | |
R:2067, 0: Too many branches (14/12) (too-many-branches) | |
E:2090,24: Undefined variable 'rbconfig' (undefined-variable) | |
C:2095,12: Invalid variable name "fd" (invalid-name) | |
E:2102,27: Undefined variable 'RBWarningError' (undefined-variable) | |
C:2111, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2119,58: Undefined variable 'rbconfig' (undefined-variable) | |
C:2122, 8: Invalid variable name "e" (invalid-name) | |
R:2108, 0: Too many branches (14/12) (too-many-branches) | |
C:2131, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2139,61: Undefined variable 'rbconfig' (undefined-variable) | |
C:2142, 8: Invalid variable name "e" (invalid-name) | |
R:2128, 0: Too many branches (14/12) (too-many-branches) | |
C:2151, 7: Do not use `len(SEQUENCE)` as condition value (len-as-condition) | |
E:2170,22: Undefined variable 'RBWarningError' (undefined-variable) | |
C:2171, 8: Invalid variable name "e" (invalid-name) | |
R:2148, 0: Too many branches (16/12) (too-many-branches) | |
C:2177, 0: Missing function docstring (missing-docstring) | |
E:2179,14: Undefined variable 'RBFatalError' (undefined-variable) | |
C:2185, 0: Invalid argument name "e" (invalid-name) | |
E:2205,25: Undefined variable 'RBWarningError' (undefined-variable) | |
R:2212,12: Unnecessary "else" after "return" (no-else-return) | |
W:2200, 4: Unused variable 'res' (unused-variable) | |
R:2185, 0: Too many branches (14/12) (too-many-branches) | |
C:2227, 0: Invalid argument name "e" (invalid-name) | |
R: 1, 0: Similar lines in 2 files | |
==useradm:9 | |
==useradm:9 | |
import atexit | |
import getopt | |
import os | |
import pprint | |
import re | |
import readline | |
import sys | |
# RedBrick modules | |
from rbaccount import RBAccount | |
from rbuser import RBUser | |
from rbuserdb import RBUserDB | |
from rbopt import RBOpt | |
from rberror import RBError | |
#-----------------------------------------------------------------------------# | |
# DATA # | |
#-----------------------------------------------------------------------------# | |
__version__ = '$Revision: 1.17 $' | |
__author__ = 'Cillian Sharkey' | |
# Command name -> (command description, optional arguments) | |
# | |
cmds = { | |
'add': ('Add new user', '[username]'), | |
'renew': ('Renew user', '[username]'), | |
'update': ('Update user', '[username]'), | |
'altmail': ('Change Alternate Email', '[username]'), | |
'activate': ('Re-Enable a club/soc account', '[username]'), | |
'delete': ('Delete user', '[username]'), | |
'resetpw': ('Set new random password and mail it to user', '[username]'), | |
'setshell': ('Set user\'s shell', '[username [shell]]'), | |
'resetsh': ('Reset user\'s shell', '[username]'), | |
'rename': ('Rename user', '[username]'), | |
'convert': ('Change user to a different usertype', '[username]'), | |
'disuser': ('Disuser a user', '[username [new username]]'), | |
'reuser': ('Re-user a user', '[username]'), | |
'show': ('Show user details', '[username]'), | |
'info': ('Show shorter user details', '[username]'), | |
'freename': ('Check if a username is free', '[username]'), | |
'search': ('Search user and dcu databases', '[username]'), | |
'pre_sync': ('Dump LDAP tree for use by sync before new tree is loaded', ''), | |
'sync': ('Synchronise accounts with userdb (for RRS)', | |
'[rrs-logfile [presync-file]]'), | |
'sync_dcu_info': ('Interactive update of userdb using dcu database info', ''), | |
'list_users': ('List all usernames', ''), | |
'list_unavailable': ('List all usernames that are unavailable', ''), | |
'list_newbies': ('List all paid newbies', ''), | |
'list_renewals': ('List all paid renewals (non-newbie)', ''), | |
'list_unpaid': ('List all non-renewed users', ''), | |
'list_unpaid_normal': ('List all normal non-renewed users', ''), | |
'list_unpaid_reset': ('List all normal non-renewed users with reset shells', ''), | |
'list_unpaid_grace': ('List all grace non-renewed users', ''), | |
'newyear': ('Prepare database for start of new academic year', ''), | |
'unpaid_warn': ('Warn (mail) all non-renewed users', ''), | |
'unpaid_disable': ('Disable all normal non-renewed users', ''), | |
'unpaid_delete': ('Delete all grace non-renewed users', ''), | |
'checkdb': ('Check database for inconsistencies', ''), | |
'stats': ('Show database and account statistics', ''), | |
'create_uidNumber': ('Create uidNumber text file with next free uidNumber', ''), | |
} | |
# Command groups | |
# | |
cmds_single_user = ('add', 'delete', 'renew', 'update', 'altmail', 'activate', 'rename', 'convert') | |
cmds_single_account = ('resetpw', 'resetsh', 'disuser', 'reuser', 'setshell') | |
cmds_single_user_info = ('show', 'info', 'freename') | |
cmds_interactive_batch = ('search', 'sync', 'sync_dcu_info') | |
cmds_batch = ('newyear', 'unpaid_warn', 'unpaid_disable', 'unpaid_delete') | |
cmds_batch_info = ('pre_sync', 'list_users', 'list_unavailable', 'list_newbies', 'list_renewals', | |
'list_unpaid', 'list_unpaid_normal', 'list_unpaid_reset', 'list_unpaid_grace') | |
cmds_misc = ('checkdb', 'stats', 'create_uidNumber') | |
# Command group descriptions | |
# | |
cmds_group_desc = ( | |
(cmds_single_user, 'Single user commands'), | |
(cmds_single_account, 'Single account commands'), | |
(cmds_single_user_info, 'Single user information commands'), | |
(cmds_interactive_batch, 'Interactive batch commands'), | |
(cmds_batch, 'Batch commands'), | |
(cmds_batch_info, 'Batch information commands'), | |
(cmds_misc, 'Miscellaneous commands') | |
) | |
# All commands | |
# | |
cmds_all = list(cmds.keys()) | |
# Command option -> (optional argument, option description, commands that use option) | |
# | |
cmds_opts = ( | |
('h', '', 'Display this usage', cmds_all), | |
('T', '', 'Test mode, show what would be done', cmds_all), | |
('d', '', 'Perform database operations only', cmds_single_user), | |
('a', '', 'Perform unix account operations only', cmds_single_user), | |
('u', 'username', 'Unix username of who updated this user', | |
cmds_single_user + ('disuser', 'reuser')), | |
('f', '', 'Set newbie (fresher) to true', ('add', 'update')), | |
('F', '', 'Opposite of -f', ('add', 'update')), | |
('m', '', 'Send account details to user\'s alternate email address', | |
('add', 'renew', 'rename', 'resetpw')), | |
('M', '', 'Opposite of -m', ('add', 'renew', 'rename', 'resetpw')), | |
('o', '', 'Override warning errors', cmds_all), | |
('p', '', 'Set new random password', ('add', 'renew')), | |
('P', '', 'Opposite of -p', ('add', 'renew')), | |
('t', 'usertype', 'Type of account', ('add', 'renew', 'update', 'convert')), | |
('n', 'name', 'Real name or account description', ('add', 'renew', 'update', 'search')), | |
('e', 'email', 'Alternative email address', ('add', 'renew', 'update')), | |
('i', 'id', 'Student/Staff ID', ('add', 'renew', 'update', 'search')), | |
('c', 'course', 'DCU course (abbreviation)', ('add', 'renew', 'update')), | |
('y', 'year', 'DCU year', ('add', 'renew', 'update')), | |
('s', 'years', 'paid Number of years paid (subscription)', ('add', 'renew', 'update')), | |
('b', 'birthday', 'Birthday (format YYYY-MM-DD)', ('add', 'renew', 'update')), | |
('q', '', 'Quiet mode', ('reuser',)) | |
) | |
input_instructions = '\033[1mRETURN\033[0m: use [default] given \033[1mTAB\033[0m: answer completion \033[1mEOF\033[0m: give empty answer\n' | |
# Global variables. | |
# | |
opt = RBOpt() | |
udb = acc = None # Initialised later in main() | |
header_mesg = None | |
#-----------------------------------------------------------------------------# | |
# MAIN # | |
#-----------------------------------------------------------------------------# | |
def main(): | |
"""Program entry function.""" | |
atexit.register(shutdown) | |
if len(sys.argv) > 1 and sys.argv[1][0] != '-': | |
opt.mode = sys.argv.pop(1) | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], 'b:c:e:i:n:s:t:u:y:adfFhmMopPqT') | |
except getopt.GetoptError as err: | |
print(err) | |
usage() | |
sys.exit(1) | |
for o, a in opts: | |
if o == '-h': | |
opt.help = 1 | |
usage() | |
sys.exit(0) | |
elif o == '-T': | |
opt.test = 1 | |
elif o == '-d': | |
opt.dbonly = 1 | |
opt.aconly = 0 | |
elif o == '-a': | |
opt.aconly = 1 | |
opt.dbonly = 0 | |
elif o == '-u': | |
opt.updatedby = a | |
elif o == '-f': | |
opt.newbie = 1 | |
elif o == '-F': | |
opt.newbie = 0 | |
elif o == '-m': | |
opt.mailuser = 1 | |
elif o == '-M': | |
opt.mailuser = 0 | |
elif o == '-o': | |
opt.override = 1 | |
elif o == '-p': | |
opt.setpasswd = 1 | |
elif o == '-P': | |
opt.setpasswd = 0 | |
elif o == '-t': | |
opt.usertype = a | |
elif o == '-n': | |
opt.cn = a | |
elif o == '-e': | |
opt.altmail = a | |
elif o == '-i': | |
opt.id = a | |
elif o == '-c': | |
opt.course = a | |
elif o == '-y': | |
opt.year = a | |
elif o == '-s': | |
opt.yearsPaid = a | |
elif o == '-b': | |
opt.birthday = a | |
elif o == '-q': | |
opt.quiet = 1 | |
if opt.mode not in cmds: | |
usage() | |
sys.exit(1) | |
global udb, acc | |
udb = RBUserDB() | |
try: | |
udb.connect() | |
except ldap.LDAPError as err: | |
error(err, 'Could not connect to user database') | |
# not reached | |
except KeyboardInterrupt: | |
print() | |
sys.exit(1) | |
# not reached | |
acc = RBAccount() | |
# Optional additional parameters after command line options. | |
opt.args = args | |
try: | |
# Call function for specific mode. | |
eval(opt.mode + "()") | |
except KeyboardInterrupt: | |
print() | |
sys.exit(1) | |
# not reached | |
except RBError as err: | |
rberror(err) | |
# not reached | |
except ldap.LDAPError as err: | |
error(err) | |
# not reached | |
sys.exit(0) | |
def shutdown(): | |
"""Cleanup function registered with atexit.""" | |
if udb: udb.close() | |
def usage(): | |
"""Print command line usage and options.""" | |
if opt.mode and opt.mode not in cmds: | |
print(("Unknown command '%s'" % opt.mode)) | |
opt.mode = None | |
if not opt.mode: | |
print("Usage: useradm command [options]") | |
if opt.help: | |
for grp in cmds_group_desc: | |
print(("[1m%s:[0m" % (grp[1]))) | |
for cmd in grp[0]: | |
print((" %-20s %s" % (cmd, cmds[cmd][0]))) | |
print("'useradm command -h' for more info on a command's options & usage.") | |
else: | |
print("'useradm -h' for more info on available commands") | |
else: | |
print((cmds[opt.mode][0])) | |
print(("Usage: useradm", opt.mode, "[options]", cmds[opt.mode][1])) | |
for i in cmds_opts: | |
if opt.mode in i[3]: | |
print((" -%s %-15s%s" % (i[0], i[1], i[2]))) | |
#=============================================================================# | |
# MAIN FUNCTIONS # | |
#=============================================================================# | |
#-----------------------------------------------------------------------------# | |
# SINGLE USER COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def add(): | |
"""Add a new user.""" | |
usr = RBUser() | |
get_usertype(usr) | |
get_freeusername(usr) | |
oldusertype = usr.usertype | |
while 1: | |
try: | |
get_id(usr) | |
udb.get_userinfo_new(usr, override = 1) | |
except RBError as e: | |
if not rberror(e, opt.id == None): | |
break | |
usr.id = None | |
else: | |
break | |
udb.get_userdefaults_new(usr) | |
# If we get info from the DCU databases, show the user details and any | |
# differences to previous data (in this case it's just the initial | |
# usertype entered at first) and offer to edit these with a default of | |
# no so we can hit return and quickly add a user without verifying each | |
# attribute. | |
# | |
if usr.cn: | |
udb.show(usr) | |
print() | |
if oldusertype != usr.usertype: | |
print('NOTICE: Given usertype is different to one determined by DCU database!') | |
print() | |
edit_details = yesno('Details of user to be added are shown above. Edit user details?', 0) | |
else: | |
edit_details = 1 | |
if edit_details: | |
get_usertype(usr) | |
get_newbie(usr) | |
get_name(usr) | |
get_email(usr) | |
get_course(usr) | |
get_year(usr) | |
get_years_paid(usr) | |
get_birthday(usr) | |
get_createaccount(usr) | |
get_setpasswd(usr) | |
get_mailuser(usr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
# | |
udb.setopt(opt) | |
acc.setopt(opt) | |
if opt.setpasswd: | |
usr.passwd = rbconfig.gen_passwd() | |
if not opt.aconly: | |
print(("User added: %s %s (%s)" % (usr.usertype, usr.uid, usr.cn))) | |
udb.add(usr) | |
if not opt.dbonly: | |
print(("Account created: %s %s password: %s" % (usr.usertype, usr.uid, usr.passwd))) | |
acc.add(usr) | |
else: | |
# If not creating a Unix account but setting a new password is | |
# required, do that now. | |
# | |
if opt.setpasswd: | |
print(("Account password set for %s password: %s" % (usr.uid, usr.passwd))) | |
#acc.setpasswd(usr.uid, usr.passwd) | |
if opt.mailuser: | |
print(("User mailed:", usr.altmail)) | |
mailuser(usr) | |
def delete(): | |
"""Delete user.""" | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
if not opt.aconly: | |
print(('User deleted:', usr.uid)) | |
udb.delete(usr) | |
if not opt.dbonly: | |
print(('Account deleted:', usr.uid)) | |
acc.delete(usr) | |
def renew(): | |
"""Renew user.""" | |
usr = RBUser() | |
curusr = RBUser() | |
get_username(usr) | |
try: | |
udb.get_userinfo_renew(usr, curusr, override=1) | |
except RBError as err: | |
if rberror(err, opt.uid is None): | |
return | |
try: | |
udb.check_unpaid(curusr) | |
except RBError as err: | |
if rberror(err, opt.uid is None): | |
return | |
udb.get_userdefaults_renew(usr) | |
udb.show_diff(usr, curusr) | |
print() | |
if curusr.usertype != usr.usertype: | |
print('NOTICE: A new usertype was determined by DCU database!') | |
print() | |
edit_details = yesno( | |
'New details of user to be renewed are shown above with any differences\n' \ | |
'from current values. Edit user details?', 0) | |
if edit_details: | |
while 1: | |
get_id(usr) | |
try: | |
# If id was changed, need to get updated user info. | |
# | |
udb.get_userinfo_renew(usr, override = 1) | |
# XXX: check id not already in use | |
except RBError as err: | |
if not rberror(err, opt.id is None): | |
break | |
else: | |
break | |
if curusr.id != usr.id: | |
udb.show_diff(usr, curusr) | |
print() | |
get_usertype(usr) | |
get_newbie(usr) | |
get_name(usr, (curusr.cn,)) | |
get_email(usr, (curusr.altmail,)) | |
get_course(usr, (curusr.course,)) | |
get_year(usr, (curusr.year,)) | |
get_years_paid(usr) | |
get_birthday(usr) | |
get_setpasswd(usr) | |
get_mailuser(usr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
if not opt.aconly: | |
print(('User renewed:', usr.uid)) | |
udb.renew(usr) | |
if opt.setpasswd: | |
usr.passwd = rbconfig.gen_passwd() | |
print(("Account password reset: %s password: %s" % (usr.uid, usr.passwd))) | |
udb.set_passwd(usr) | |
if curusr.usertype != usr.usertype: | |
if not opt.aconly: | |
print(('User converted: %s -> %s' % (usr.uid, usr.usertype))) | |
udb.convert(curusr, usr) | |
if not opt.dbonly: | |
print(('Account converted: %s -> %s' % (usr.uid, usr.usertype))) | |
acc.convert(curusr, usr) | |
if udb.reset_shell(usr): | |
print(('Account shell reset for', usr.uid, '(%s)' % usr.loginShell)) | |
if opt.mailuser: | |
print(("User mailed:", usr.altmail)) | |
mailuser(usr) | |
def update(): | |
"""Update user.""" | |
# Update mode only works on database. | |
opt.dbonly = 1 | |
opt.aconly = 0 | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
get_newbie(usr) | |
defid = usr.id | |
while 1: | |
try: | |
get_id(usr) | |
newusr = RBUser(id = usr.id) | |
if usr.id != None: | |
udb.get_dcu_byid(newusr) | |
except RBError as e: | |
if not rberror(e, opt.id == None): | |
break | |
usr.id = defid | |
else: | |
break | |
get_name(usr, (newusr.cn,)) | |
get_email(usr, (newusr.altmail,)) | |
get_course(usr, (newusr.course,)) | |
get_year(usr, (newusr.year,)) | |
get_years_paid(usr) | |
get_birthday(usr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
print(("User updated:", usr.uid)) | |
udb.update(usr) | |
def altmail(): | |
"""Update user.""" | |
# Update mode only works on database. | |
opt.dbonly = 1 | |
opt.aconly = 0 | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
# get_newbie(usr) | |
defid = usr.id | |
while 1: | |
try: | |
get_id(usr) | |
newusr = RBUser(id = usr.id) | |
if usr.id != None: | |
udb.get_dcu_byid(newusr) | |
except RBError as e: | |
if not rberror(e, opt.id == None): | |
break | |
usr.id = defid | |
else: | |
break | |
get_email(usr, (newusr.altmail,)) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
print(("User updated:", usr.uid)) | |
udb.update(usr) | |
def activate(): | |
"""Update user.""" | |
# Update mode only works on database. | |
# opt.dbonly = 1 | |
# opt.aconly = 0 | |
print(" ") | |
print("To confirm society committee details check:") | |
print("https://www.dcu.ie/portal/index.php3?club_soc_registration_function=8") | |
print("Continuing will mail a new password for this account,") | |
print("and set the shell to /usr/local/shells/zsh") | |
print(" ") | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
# if we're activating them they're hardly newbies | |
# get_newbie(usr) | |
defid = usr.id | |
while 1: | |
try: | |
get_id(usr) | |
newusr = RBUser(id = usr.id) | |
if usr.id != None: | |
udb.get_dcu_byid(newusr) | |
except RBError as e: | |
if not rberror(e, opt.id == None): | |
break | |
usr.id = defid | |
else: | |
break | |
get_email(usr, (newusr.altmail,)) | |
# everyone likes zsh | |
# get_shell(usr) | |
usr.loginShell = "/usr/local/shells/zsh" | |
# Don't bother asking, assume we want to do it | |
# get_setpasswd(usr) | |
# Again, we always want to do this. | |
# get_mailuser(usr) | |
get_updatedby(usr) | |
usr.passwd = rbconfig.gen_passwd() | |
print(("Account password reset: %s password: %s" % (usr.uid, usr.passwd))) | |
udb.set_passwd(usr) | |
print(("User mailed:", usr.altmail)) | |
mailuser(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
udb.update(usr) | |
print(('Account email & shell set for', usr.uid, '(%s)' % usr.loginShell)) | |
udb.set_shell(usr) | |
def rename(): | |
"""Rename user.""" | |
usr = RBUser() | |
newusr = RBUser() | |
get_username(usr) | |
get_freeusername(newusr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
print(('User renamed: %s -> %s' % (usr.uid, newusr.uid))) | |
udb.rename(usr, newusr) | |
print(('Account renamed: %s -> %s' % (usr.uid, newusr.uid))) | |
acc.rename(usr, newusr) | |
def convert(): | |
"""Convert user.""" | |
usr = RBUser() | |
newusr = RBUser() | |
get_username(usr) | |
get_convert_usertype(newusr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
if not opt.aconly: | |
print('User converted: %s -> %s' % (usr.uid, newusr.usertype)) | |
udb.convert(usr, newusr) | |
if not opt.dbonly: | |
print('Account converted: %s -> %s' % (usr.uid, newusr.usertype)) | |
acc.convert(usr, newusr) | |
#-----------------------------------------------------------------------------# | |
# SINGLE ACCOUNT COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def resetpw(): | |
"""Set new random password and mail it to user.""" | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
usr.passwd = rbconfig.gen_passwd() | |
check_paid(usr) | |
get_mailuser(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
#print "Account password reset: %s password: %s" % (usr.uid, usr.passwd) | |
print("Account password reset: %s " % (usr.uid)) | |
udb.set_passwd(usr) | |
if opt.mailuser: | |
print("User mailed:", usr.altmail) | |
mailuser(usr) | |
def resetsh(): | |
"""Reset user's shell.""" | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
check_paid(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
if udb.reset_shell(usr): | |
print('Account shell reset for', usr.uid, '(%s)' % usr.loginShell) | |
else: | |
print('Account', usr.uid, 'already had valid shell, no action performed.') | |
def disuser(): | |
"""Disuser a user.""" | |
raise RBFatalError("NOT IMPLEMENTED YET") | |
usr = RBUser() | |
get_username(usr) | |
get_disuser_period(usr) | |
get_disuser_message(usr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
acc.disuser(usr.uid, usr.disuser_period) | |
def reuser(): | |
"""Re-user a user.""" | |
raise RBFatalError("NOT IMPLEMENTED YET") | |
usr = RBUser() | |
get_username(usr) | |
get_updatedby(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
def setshell(): | |
"""Set user's shell.""" | |
usr = RBUser() | |
get_username(usr) | |
udb.get_user_byname(usr) | |
check_paid(usr) | |
get_shell(usr) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
print('Account shell set for', usr.uid, '(%s)' % usr.loginShell) | |
udb.set_shell(usr) | |
#-----------------------------------------------------------------------------# | |
# SINGLE USER INFORMATION COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def show(): | |
"""Show user's database and account details.""" | |
usr = RBUser() | |
get_username(usr, check_user_exists = 0) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
udb.get_user_byname(usr) | |
print(header('User Information')) | |
udb.show(usr) | |
print(header('Account Information')) | |
acc.show(usr) | |
def info(): | |
"""Show user's database and account details.""" | |
usr = RBUser() | |
get_username(usr, check_user_exists = 0) | |
# End of user interaction, set options for override & test mode. | |
udb.setopt(opt) | |
udb.get_user_byname(usr) | |
print(header('User Information')) | |
udb.info(usr) | |
def freename(): | |
"""Check if a username is free.""" | |
usr = RBUser() | |
if get_freeusername(usr): | |
print("Username '%s' is free." % (usr.uid)) | |
#-----------------------------------------------------------------------------# | |
# BATCH INTERACTIVE COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def search(): | |
"""Search user and/or DCU databases.""" | |
raise RBFatalError("NOT IMPLEMENTED YET") | |
pager = os.environ.get('PAGER', 'more') | |
username = None | |
if len(opt.args) > 0: | |
username = opt.args.pop(0) | |
if not username and not opt.id and not opt.cn: | |
username = ask('Enter username to search user database', optional = 1) | |
if not username: | |
opt.id = ask('Enter DCU Id number to search user and DCU databases', optional = 1) | |
if not opt.id: | |
opt.cn = ask('Enter name to search user and DCU databases', optional = 1) | |
if username: | |
res = udb.search_users_byusername(username) | |
fd = os.popen(pager, 'w') | |
print("User database search for username '%s' - %d match%s\n" % (username, len(res), len(res) != 1 and 'es' or ''), file=fd) | |
show_search_results(res, fd) | |
fd.close() | |
elif opt.id or opt.cn: | |
fd = os.popen(pager, 'w') | |
if opt.id: | |
res = udb.search_users_byid(opt.id) | |
print("User database search for id '%s' - %d match%s\n" % (opt.id, len(res), len(res) != 1 and 'es' or ''), file=fd) | |
else: | |
res = udb.search_users_byname(opt.cn) | |
print("User database search for name '%s' - %d match%s\n" % (opt.cn, len(res), len(res) != 1 and 'es' or ''), file=fd) | |
show_search_results(res, fd) | |
print(file=fd) | |
if opt.id: | |
res = udb.search_dcu_byid(opt.id) | |
print("DCU database search for id '%s' - %d match%s\n" % (opt.id, len(res), len(res) != 1 and 'es' or ''), file=fd) | |
else: | |
res = udb.search_dcu_byname(opt.cn) | |
print("DCU database search for name '%s' - %d match%s\n" % (opt.cn, len(res), len(res) != 1 and 'es' or ''), file=fd) | |
show_search_results(res, fd) | |
fd.close() | |
else: | |
raise RBFatalError('No search term given!') | |
def show_search_results(res, fd): | |
"""Actual routine to display search results on given output steam.""" | |
if res: | |
print('%-*s %-*s %-8s %-30s %-6s %-4s %s' % (rbconfig.maxlen_uname, 'username', rbconfig.maxlen_group, 'usertype', 'id', 'name', 'course', 'year', 'email'), file=fd) | |
print('%s %s %s %s %s %s %s' % ('-' * rbconfig.maxlen_uname, '-' * rbconfig.maxlen_group, '-' * 8, '-' * 30, '-' * 6, '-' * 4, '-' * 30), file=fd) | |
for username, usertype, id, name, course, year, email in res: | |
print("%-*s %-*s %-8s %-30.30s %-6.6s %-4.4s %s" % (rbconfig.maxlen_uname, username or '-', rbconfig.maxlen_group, usertype or '-', id != None and id or '-', name, course or '-', year or '-', email), file=fd) | |
def pre_sync(): | |
"""Dump current LDAP information to a file for use by sync(). | |
This step is performed before the new LDAP accounts tree is loaded so | |
that a bare minimum copy of the old tree is available.""" | |
get_pre_sync() | |
print('Dumping...') | |
fd = open(opt.presync, 'w') | |
print('global old_ldap\nold_ldap = ', end=' ', file=fd) | |
pprint.pprint(udb.list_pre_sync(), fd) | |
fd.close() | |
def sync(): | |
"""Synchronise accounts (i.e. no changes are made to userdb) after an | |
offline update to user database with RRS. Needs rrs.log to process | |
renames and password resets for existing accounts. | |
Procedure: | |
1. Process all renames, only applicable to existing accounts. Taken from | |
rrs.log. Keep a mapping of username renewals. Note there may be | |
multiple rename entries. | |
2. Process all conversions, only applicable to existing accounts. | |
Detected by comparing Unix group and usertype in database. | |
3. Process all deletions, only applicable to existing accounts. | |
Detected by checking for unix accounts missing a database entry. All | |
accounts should be renamed all ready so the only accounts left with | |
missing database entries must have been deleted. Confirmation is | |
required for each deletion, however. | |
4. Process all adds, only applicable to new users. Detected by user | |
database entry being a newbie, paid and having no unix account. | |
Password is generated on-the-fly and mailed. | |
5. Process all renewals, only applicable to existing users. Detected by | |
user database entry being a non-newbie, paid and having an existing | |
unix account. Reset account shell if needed. Password is reset | |
on-the-fly and mailed if flagged in rrs.log. The flag in the logfile | |
will be marked on the original username so the rename map is used to | |
map this to the current username. | |
""" | |
get_rrslog() | |
get_pre_sync() | |
# Load in old_ldap dictionary. | |
# | |
exec(compile(open(opt.presync).read(), opt.presync, 'exec')) | |
# XXX: Set override by default ? | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
# Build user_rename maps. | |
user_convert = {} | |
user_rename = {} | |
user_rename_reverse = {} | |
user_rename_stages = {} | |
reset_password = {} | |
# Open log file to build map of renamed usernames, usernames flagged | |
# for a new password and usernames that were converted. | |
# | |
fd = open(opt.rrslog, 'r') | |
for line in fd.readlines(): | |
tlog = line.rstrip().split(':') | |
# We ignore renames of new accounts as we just go by the final | |
# entry in the database. | |
# | |
if tlog[4] == 'rename-existing': | |
olduid = tlog[5] | |
newuid = tlog[6] | |
# Remove old user rename mapping and add new one unless | |
# it points back to the original username. | |
# | |
user_rename_reverse[newuid] = user_rename_reverse.pop(olduid, olduid) | |
if user_rename_reverse[newuid] == newuid: | |
user_rename_reverse.pop(newuid) | |
# If this user was flagged for new password and/or a | |
# conversion, remove the old user mapping and add the | |
# new one. | |
# | |
if olduid in user_convert: | |
user_convert[tlog[6]] = user_convert.pop(tlog[5]) | |
if tlog[5] in reset_password: | |
reset_password[tlog[6]] = reset_password.pop(tlog[5]) | |
elif tlog[4] == 'convert': | |
# User was converted, so we flag it. Don't care what | |
# they're converted to, we check that later. | |
# | |
user_convert[tlog[5]] = 1 | |
elif tlog[4] == 'renew': | |
# tlog[7] indicates whether a new password is required | |
# or not. We take the last value of this in the log | |
# file as the final decision. | |
# | |
reset_password[tlog[5]] = int(tlog[7]) | |
fd.close() | |
# Now build olduid -> newuid map from the reverse one. | |
# | |
for newuid, olduid in list(user_rename_reverse.items()): | |
user_rename[olduid] = newuid | |
if opt.test: | |
print('rrs.log username maps') | |
print() | |
print('RENAME') | |
print() | |
for k, v in list(user_rename.items()): | |
print(k, '->', v) | |
print() | |
print('CONVERT') | |
print() | |
for k in list(user_convert.keys()): | |
print(k) | |
print() | |
print('RESETPW') | |
print() | |
for k, v in list(reset_password.items()): | |
if v: print(k) | |
print() | |
#-------------# | |
# sync_rename # | |
#-------------# | |
print('===> start sync_rename') | |
pause() | |
for olduid, newuid in list(user_rename.items()): | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory']) | |
newusr = RBUser(uid = newuid) | |
udb.get_user_byname(newusr) | |
try: | |
acc.check_account_byname(oldusr) | |
except RBFatalError: | |
# Old account doesn't exist, must be renamed already. | |
if opt.test: | |
print('SKIPPED: account rename: %s -> %s' % (olduid, newuid)) | |
else: | |
print('Account renamed: %s -> %s' % (olduid, newuid)) | |
acc.rename(oldusr, newusr) | |
#pause() | |
#--------------# | |
# sync_convert # | |
#--------------# | |
print('\n===> start sync_convert') | |
pause() | |
for newuid in list(user_convert.keys()): | |
olduid = user_rename_reverse.get(newuid, newuid) | |
if olduid not in old_ldap: | |
print('WARNING: Existing non newbie user', newuid, 'not in previous copy of ldap tree!') | |
continue | |
oldusr = RBUser(uid = olduid, homeDirectory = old_ldap[olduid]['homeDirectory'], usertype = old_ldap[olduid]['usertype']) | |
newusr = RBUser(uid = newuid) | |
udb.get_user_byname(newusr) | |
# If old and new usertypes are the same, they were temporarily | |
# or accidentally converted to a different usertype then | |
# converted back. | |
# | |
if oldusr.usertype == newusr.usertype: | |
continue | |
try: | |
acc.check_account_byname(oldusr) | |
except RBFatalError: | |
# Old account doesn't exist, must be converted already. | |
if opt.test: | |
print('SKIPPED: account convert: %s: %s -> %s' % (oldusr.uid, oldusr.usertype, newusr.usertype)) | |
else: | |
print('Account converted: %s: %s -> %s' % (oldusr.uid, oldusr.usertype, newusr.usertype)) | |
acc.convert(oldusr, newusr) | |
#pause() | |
#-------------# | |
# sync_delete # | |
#-------------# | |
#print '\n===> start sync_delete' | |
#pause() | |
#for pw in pwd.getpwall(): | |
# try: | |
# udb.check_user_byname(pw[0]) | |
# except RBError: | |
# # User doesn't exist in database, ask to delete it. | |
# # | |
# if yesno("Delete account %s" % pw[0]): | |
# print 'Account deleted: %s' % pw[0] | |
# acc.delete(pw[0]) | |
# else: | |
# # User exists in database, do nothing! | |
# pass | |
#----------# | |
# sync_add # | |
#----------# | |
print('\n===> start sync_add') | |
pause() | |
for username in udb.list_newbies(): | |
usr = RBUser(uid = username) | |
udb.get_user_byname(usr) | |
try: | |
acc.check_account_byname(usr) | |
except RBFatalError: | |
usr.passwd = rbconfig.gen_passwd() | |
# print 'Account password set for %s password: %s' % (usr.uid, usr.passwd) | |
udb.set_passwd(usr) | |
print("Account created: %s %s" % (usr.usertype, usr.uid)) | |
acc.add(usr) | |
print("User mailed:", usr.altmail) | |
mailuser(usr) | |
#pause() | |
else: | |
# New account exists, must be created already. | |
if opt.test: | |
print('SKIPPED: account create:', usr.usertype, usr.uid) | |
#------------# | |
# sync_renew # | |
#------------# | |
print('\n===> start sync_renew') | |
pause() | |
if not os.path.isdir('renewal_mailed'): | |
os.mkdir('renewal_mailed') | |
for newuid in udb.list_paid_non_newbies(): | |
action = 0 | |
olduid = user_rename_reverse.get(newuid, newuid) | |
if olduid not in old_ldap: | |
print('WARNING: Existing non newbie user', newuid, 'not in previous copy of ldap tree!') | |
continue | |
newusr = RBUser(uid = newuid) | |
udb.get_user_byname(newusr) | |
try: | |
acc.check_account_byname(newusr) | |
except RBFatalError: | |
# Accounts should be renamed & converted by now, so we | |
# should never get here! | |
# | |
print("SKIPPED: User", newuid, "missing account. Earlier rename/conversion not completed?") | |
continue | |
if not udb.valid_shell(newusr.loginShell): | |
newusr.loginShell = udb.get_backup_shell(olduid) | |
print('Account shell reset for:', newuid, '(%s)' % newusr.loginShell) | |
udb.set_shell(newusr) | |
action = 1 | |
if not os.path.exists('renewal_mailed/%s' % newusr.uid): | |
# Set a new password if they need one. | |
# | |
if reset_password.get(newuid): | |
newusr.passwd = rbconfig.gen_passwd() | |
print('Account password reset for %s password: %s' % (newuid, newusr.passwd)) | |
udb.set_passwd(newusr) | |
action = 1 | |
# Send a mail to people who renewed. All renewals should have | |
# an entry in reset_password i.e. 0 or 1. | |
# | |
if newuid in reset_password: | |
print('User mailed:', newusr.uid, '(%s)' % newusr.altmail) | |
mailuser(newusr) | |
action = 1 | |
# Flag this user as mailed so we don't do it again if | |
# sync is rerun. | |
# | |
if not opt.test: | |
open('renewal_mailed/%s' % newusr.uid, 'w').close() | |
elif opt.test: | |
print('SKIPPED: User mailed:', newusr.uid) | |
#if action: | |
# pause() | |
print() | |
print('sync completed.') | |
def sync_dcu_info(): | |
"""Interactive update of user database using dcu database information.""" | |
raise RBFatalError("NOT IMPLEMENTED YET") | |
print('Comparing user and DCU databases. NOTE: please be patient') | |
print('this takes some time...\n') | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
#-----------------------------------------------------------------------------# | |
# BATCH INFORMATION COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def list_users(): | |
"""List all usernames.""" | |
for username in udb.list_users(): | |
print(username) | |
def list_newbies(): | |
"""List all paid newbies.""" | |
for username in udb.list_paid_newbies(): | |
print(username) | |
def list_renewals(): | |
"""List all paid renewals (non-newbie).""" | |
for username in udb.list_paid_non_newbies(): | |
print(username) | |
def list_unavailable(): | |
"""List all usernames that are taken.""" | |
for username in udb.list_reserved_all(): | |
print(username) | |
def list_unpaid(): | |
"""Print list of all non-renewed users.""" | |
for username in udb.list_unpaid(): | |
print(username) | |
def list_unpaid_normal(): | |
"""Print list of all normal non-renewed users.""" | |
for username in udb.list_unpaid_normal(): | |
print(username) | |
def list_unpaid_reset(): | |
"""Print list of all normal non-renewed users with reset shells (i.e. not expired).""" | |
for username in udb.list_unpaid_reset(): | |
print(username) | |
def list_unpaid_grace(): | |
"""Print list of all grace non-renewed users.""" | |
for username in udb.list_unpaid_grace(): | |
print(username) | |
#-----------------------------------------------------------------------------# | |
# BATCH COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def newyear(): | |
"""Prepare database for start of new academic year.""" | |
raise RBFatalError("NOT IMPLEMENTED YET") | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
print('Prepared database for start of new academic year') | |
udb.newyear() | |
def unpaid_warn(): | |
"""Mail a reminder/warning message to all non-renewed users.""" | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
for username in udb.list_unpaid(): | |
usr = RBUser(uid = username) | |
udb.get_user_byname(usr) | |
print("Warned user:", username) | |
mail_unpaid(usr) | |
def unpaid_disable(): | |
"""Disable all normal non-renewed users.""" | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
for username in udb.list_unpaid_reset(): | |
print("Account disabled:", username) | |
udb.set_shell(RBUser(uid = username, loginShell = rbconfig.shell_expired)) | |
def unpaid_delete(): | |
"""Delete all grace non-renewed users.""" | |
# Set options for override & test mode. | |
udb.setopt(opt) | |
acc.setopt(opt) | |
for username in udb.list_unpaid_grace(): | |
usr = RBUser(uid = username) | |
udb.get_user_byname(usr) | |
print('User deleted:', username) | |
udb.delete(usr) | |
print('Account deleted:', username) | |
acc.delete(usr) | |
#-----------------------------------------------------------------------------# | |
# MISCELLANEOUS COMMANDS # | |
#-----------------------------------------------------------------------------# | |
def checkdb(): | |
"""Check database for inconsistencies.""" | |
uidNumbers = {} | |
re_mail = re.compile(r'.+@.*dcu\.ie', re.I) | |
set_header('User database problems') | |
unpaid_valid_shells = 0 | |
reserved = udb.dict_reserved_desc() | |
for uid in udb.list_users(): | |
usr = RBUser(uid=uid) | |
udb.get_user_byname(usr) | |
desc = reserved.get(uid) | |
if desc: | |
show_header() | |
print('%-*s is reserved: %s' % (rbconfig.maxlen_uname, uid, desc)) | |
if usr.uidNumber not in uidNumbers: | |
uidNumbers[usr.uidNumber] = [uid] | |
else: | |
uidNumbers[usr.uidNumber].append(uid) | |
if usr.usertype == 'member': | |
try: | |
udb.get_student_byid(usr) | |
except RBWarningError: | |
show_header() | |
print('%-*s is a member without a valid DCU student id: %s' % (rbconfig.maxlen_uname, uid, usr.id)) | |
if usr.yearsPaid != None: | |
if not -1 <= usr.yearsPaid <= 5: | |
show_header() | |
print('%-*s has bogus yearsPaid: %s' % (rbconfig.maxlen_uname, uid, usr.yearsPaid)) | |
if usr.newbie and usr.yearsPaid < 1: | |
show_header() | |
print('%-*s is a newbie but is unpaid (yearsPaid = %s)' % (rbconfig.maxlen_uname, uid, usr.yearsPaid)) | |
if usr.yearsPaid < 1 and udb.valid_shell(usr.loginShell): | |
unpaid_valid_shells += 1 | |
if usr.yearsPaid > 0 and not udb.valid_shell(usr.loginShell): | |
show_header() | |
print('%-*s is paid but has an invalid shell: %s' % (rbconfig.maxlen_uname, uid, usr.loginShell)) | |
if usr.yearsPaid < -1: | |
print('%-*s has should have been deleted: %s' % (rbconfig.maxlen_uname, uid, usr.yearsPaid)) | |
if usr.yearsPaid == None and usr.usertype in ('member', 'associat', 'staff'): | |
show_header() | |
print('%-*s is missing a yearsPaid attribute' % (rbconfig.maxlen_uname, uid)) | |
if usr.id == None and usr.usertype in ('member', 'associat', 'staff'): | |
show_header() | |
print('%-*s is missing a DCU ID number' % (rbconfig.maxlen_uname, uid)) | |
for dir, desc in (usr.homeDirectory, 'home'), (rbconfig.gen_webtree(uid), 'webtree'): | |
if not os.path.exists(dir) or not os.path.isdir(dir): | |
show_header() | |
print('%-*s is missing %s directory: %s' % (rbconfig.maxlen_uname, uid, desc, dir)) | |
else: | |
stat = os.stat(dir) | |
if (stat.st_uid, stat.st_gid) != (usr.uidNumber, usr.gidNumber): | |
show_header() | |
print('%-*s has wrong %s ownership' % (rbconfig.maxlen_uname, uid, desc)) | |
if stat.st_mode & 0o020: | |
show_header() | |
print('%-*s has group writeable %s' % (rbconfig.maxlen_uname, uid, desc)) | |
if stat.st_mode & 0o002: | |
show_header() | |
print('%-*s has WORLD writeable %s' % (rbconfig.maxlen_uname, uid, desc)) | |
try: | |
grp = udb.get_group_byid(usr.gidNumber) | |
except RBFatalError: | |
grp = '#%d' % usr.gidNumber | |
show_header() | |
print('%-*s has unknown gidNumber: %d' % (rbconfig.maxlen_uname, uid, usr.gidNumber)) | |
if usr.usertype in ('member', 'staff', 'committe') and \ | |
(usr.altmail.lower().find('%s@redbrick.dcu.ie' % usr.uid) != -1 or \ | |
not re.search(re_mail, usr.altmail)): | |
show_header() | |
print("%-*s is a %s without a DCU altmail address: %s" % (rbconfig.maxlen_uname, uid, usr.usertype, usr.altmail)) | |
# commented by receive, it makes stuff crash | |
# if not usr.userPassword[7].isalnum() and not usr.userPassword[7] in '/.': | |
# show_header() | |
# print '%-*s has a disabled password: %s' % (rbconfig.maxlen_uname, uid, usr.userPassword) | |
if usr.usertype != 'redbrick': | |
if grp != usr.usertype: | |
show_header() | |
print('%-*s has different group [%s] and usertype [%s]' % (rbconfig.maxlen_uname, uid, grp, usr.usertype)) | |
if usr.homeDirectory != rbconfig.gen_homedir(uid, usr.usertype): | |
show_header() | |
print('%-*s has wrong home directory [%s] for usertype [%s]' % (rbconfig.maxlen_uname, uid, usr.homeDirectory, usr.usertype)) | |
if unpaid_valid_shells > 0: | |
show_header() | |
print() | |
print("There are %d shifty gits on redbrick. Unpaid users with valid" % unpaid_valid_shells) | |
print("login shells, that is. Go get 'em.") | |
set_header('Duplicate uidNumbers') | |
for uidNumber, uids in list(uidNumbers.items()): | |
if len(uids) > 1: | |
show_header() | |
print('%d is shared by: %s' % (uidNumber, ', '.join(uids))) | |
def stats(): | |
"""Show database and account statistics.""" | |
print(header('User database stats')) | |
udb.stats() | |
def create_uidNumber(): | |
"""Fine next available uidNumber and write it out to uidNumber text file.""" | |
n = udb.uidNumber_findmax() + 1 | |
print('Next available uidNumber:', n) | |
fd = open(rbconfig.file_uidNumber, 'w') | |
fd.write('%s\n' % n) | |
fd.close() | |
#-----------------------------------------------------------------------------# | |
# USER INPUT FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def ask(prompt, default = None, optional = 0, hints = None): | |
"""Ask a question using given prompt and return user's answer. | |
A default answer maybe provided which is returned if no answer is given | |
(i.e. user hits RETURN). | |
If optional is false (the default) an answer is required. So if no | |
default answer is given and the user presses RETURN, the question will | |
be repeated. | |
If optional is true, the first answer given is returned. If a default | |
is provided an empty answer may be given by sending EOF (typically | |
Control-D). If no default is provided an empty answer may be given by | |
pressing RETURN. | |
If there is more than one default answer these can be provided in the | |
form of "hints" which the user can cycle through by hitting TAB. The | |
default answer is also available by pressing TAB. | |
""" | |
def complete(text, state): | |
"""Completion function used by readline module for ask(). | |
If no text typed in yet, offer all hints. Otherwise offer only | |
hints that begin with the given text. | |
""" | |
if not text and len(hints) > state: | |
return str(hints[state]) | |
else: | |
tmp = [i for i in hints if i.startswith(text)] | |
if len(tmp) > state: | |
return str(tmp[state]) | |
return None | |
global input_instructions | |
if input_instructions: | |
print(input_instructions) | |
input_instructions = None | |
if hints == None: | |
hints = [] | |
if default == None: | |
defans = 'no default' | |
else: | |
defans = default | |
hints = [i for i in hints if i != None] | |
num_hints = len(hints) | |
if default != None: | |
if default not in hints: | |
hints.insert(0, default) | |
else: | |
num_hints -= 1 | |
prompt = '%s\n%s%s[%s] >> ' % (prompt, optional and '(optional) ' or '', num_hints and '(hints) ' or '', defans) | |
readline.parse_and_bind('tab: menu-complete') | |
readline.set_completer(complete) | |
ans = None | |
while ans == None or ans == '': | |
try: | |
ans = input(prompt) | |
except EOFError: | |
print() | |
ans = None | |
else: | |
if not ans: | |
ans = default | |
print() | |
if optional: | |
break | |
return ans | |
def yesno(prompt, default = None): | |
"""Prompt for confirmation to a question. Returns boolean.""" | |
global input_instructions | |
if input_instructions: | |
print(input_instructions) | |
input_instructions = None | |
if default == None: | |
defans = 'no default' | |
else: | |
if default: defans = 'yes' | |
else: defans = 'no' | |
prompt = '%s\n[%s] (Y/N) ? ' % (prompt, defans) | |
ans = None | |
while 1: | |
try: | |
ans = input(prompt) | |
except EOFError: | |
print() | |
ans = None | |
else: | |
print() | |
if not ans and not default == None: | |
return default | |
if ans: | |
if re.search(r'^[yY]', ans): | |
return 1 | |
elif re.search(r'^[nN]', ans): | |
return 0 | |
def pause(): | |
"""Prompt for user input to continue.""" | |
print('Press RETURN to continue...') | |
try: | |
input() | |
except EOFError: | |
pass | |
#-----------------------------------------------------------------------------# | |
# MISCELLANEOUS FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def header(mesg): | |
"""Return a simple header string for given message.""" | |
return '\n' + mesg + '\n' + '=' * len(mesg) | |
def set_header(mesg): | |
"""Set the heading for the next section.""" | |
global header_mesg | |
header_mesg = header(mesg) | |
def show_header(): | |
"""Display the heading for the current section as | |
set by set_header(). Will only print header once.""" | |
global header_mesg | |
if header_mesg: | |
print(header_mesg) | |
header_mesg = None | |
#-----------------------------------------------------------------------------# | |
# USER MAILING FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def mailuser(usr): | |
"""Mail user's account details to their alternate email address.""" | |
fd = sendmail_open() | |
fd.write( | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Welcome to Redbrick! - Your Account Details | |
To: %s | |
Reply-To: admin-request@redbrick.dcu.ie | |
""" % usr.altmail) | |
if usr.newbie: | |
fd.write("Welcome to Redbrick, the DCU Networking Society! Thank you for joining.") | |
else: | |
fd.write("Welcome back to Redbrick, the DCU Networking Society! Thank you for renewing.") | |
fd.write("\n\nYour Redbrick Account details are:\n\n") | |
fd.write('%21s: %s\n' % ('username', usr.uid)) | |
if usr.passwd: | |
fd.write('%21s: %s\n\n' % ('password', usr.passwd)) | |
fd.write('%21s: %s\n' % ('account type', usr.usertype)) | |
fd.write('%21s: %s\n' % ('name', usr.cn)) | |
if usr.id != None: | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
if usr.course: | |
fd.write('%21s: %s\n' % ('course', usr.course)) | |
if usr.year != None: | |
fd.write('%21s: %s\n' % ('year', usr.year)) | |
fd.write( | |
""" | |
------------------------------------------------------------------------------- | |
your Redbrick webpage: https://www.redbrick.dcu.ie/~%s | |
your Redbrick email: %s@redbrick.dcu.ie | |
You can find out more about our services at: | |
https://www.redbrick.dcu.ie/about/welcome | |
""" % (usr.uid, usr.uid)) | |
fd.write( | |
""" | |
We recommend that you change your password as soon as you login. | |
Problems with your password or wish to change your username? Contact: | |
admin-request@redbrick.dcu.ie | |
Problems using Redbrick in general or not sure what to do? Contact: | |
helpdesk-request@redbrick.dcu.ie | |
Have fun! | |
- Redbrick Admin Team | |
""") | |
sendmail_close(fd) | |
def mail_unpaid(usr): | |
"""Mail a warning to a non-renewed user.""" | |
fd = sendmail_open() | |
fd.write( | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: Time to renew your Redbrick account! - Note our Bank A/C Details have changed. | |
To: %s@redbrick.dcu.ie | |
""" % usr.uid) | |
if usr.altmail.lower().find('%s@redbrick.dcu.ie' % usr.uid) == -1: | |
print('Cc:', usr.altmail, file=fd) | |
fd.write( | |
"""Reply-To: accounts@redbrick.dcu.ie | |
Hey there, | |
It's that time again to renew your Redbrick account! | |
Membership prices, as set by the SLC, are as follows: | |
Members EUR 4 | |
Associates EUR 8 | |
Staff EUR 8 | |
Guests EUR 10 | |
Note: if you have left DCU, you need to apply for associate membership. | |
You can pay in person, by lodging money into our account, electronic bank | |
transfer, or even PayPal! All the details you need are here: | |
https://www.redbrick.dcu.ie/help/joining/ | |
Our bank details are: | |
a/c name: DCU Redbrick Society | |
IBAN: IE59BOFI90675027999600 | |
BIC: BOFIIE2D | |
a/c number: 27999600 | |
sort code: 90 - 67 - 50 | |
Please Note! | |
------------""") | |
######Change the message below every year###### | |
if usr.yearsPaid == 0: | |
fd.write( | |
""" | |
If you do not renew by the 30th October 2016, your account will be disabled. | |
Your account will remain on the system for a grace period of a year - you | |
just won't be able to login. So don't worry, it won't be deleted any time | |
soon! You can renew at any time during the year. | |
""") | |
else: | |
fd.write( | |
""" | |
If you do not renew within the following month, your account WILL BE | |
DELETED at the start of the new year. This is because you were not | |
recorded as having paid for last year and as such are nearing the end of | |
your one year 'grace' period to renew. Please make sure to renew as soon | |
as possible otherwise please contact us at: accounts@redbrick.dcu.ie. | |
""") | |
fd.write( | |
""" | |
If in fact you have renewed and have received this email in error, it is | |
important you let us know. Just reply to this email and tell us how and | |
when you renewed and we'll sort it out. | |
For your information, your current Redbrick account details are: | |
username: %s | |
account type: %s | |
name: %s | |
alternative email: %s | |
""" % (usr.uid, usr.usertype, usr.cn, usr.altmail)) | |
if usr.id != None: | |
fd.write('%21s: %s\n' % ('id number', usr.id)) | |
if usr.course: | |
fd.write('%21s: %s\n' % ('course', usr.course)) | |
if usr.year != None: | |
fd.write('%21s: %s\n' % ('year', usr.year)) | |
fd.write( | |
""" | |
If any of the above details are wrong, please correct them when you | |
renew! | |
- Redbrick Admin Team | |
""") | |
sendmail_close(fd) | |
def mail_committee(subject, body): | |
"""Email committee with given subject and message body.""" | |
fd = sendmail_open() | |
fd.write( | |
"""From: Redbrick Admin Team <admins@redbrick.dcu.ie> | |
Subject: %s | |
To: committee@redbrick.dcu.ie | |
%s | |
""" % (subject, body)) | |
sendmail_close(fd) | |
def sendmail_open(): | |
"""Return file descriptor to write email message to.""" | |
if opt.test: | |
print(header('Email message that would be sent'), file=sys.stderr) | |
return sys.stderr | |
else: | |
return os.popen('%s -t -i' % rbconfig.command_sendmail, 'w') | |
def sendmail_close(fd): | |
"""Close sendmail file descriptor.""" | |
if not opt.test: | |
fd.close() | |
#-----------------------------------------------------------------------------# | |
# GET USER DATA FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def get_username(usr, check_user_exists = 1): | |
"""Get an existing username.""" | |
if len(opt.args) > 0 and opt.args[0]: | |
usr.uid = opt.uid = opt.args.pop(0) | |
interact = 0 | |
else: | |
interact = 1 | |
while 1: | |
if interact: | |
usr.uid = ask('Enter username') | |
try: | |
udb.check_username(usr.uid) | |
if check_user_exists: | |
print("Checking user exists") | |
tmpusr = RBUser(uid = usr.uid) | |
udb.get_user_byname(tmpusr) | |
udb.check_user_byname(usr.uid) | |
acc.check_account_byname(tmpusr) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
if not interact: | |
break | |
def get_freeusername(usr): | |
"""Get a new (free) username.""" | |
if len(opt.args) > 0 and opt.args[0]: | |
usr.uid = opt.uid = opt.args.pop(0) | |
interact = 0 | |
else: | |
interact = 1 | |
while 1: | |
if interact: | |
usr.uid = ask('Enter new username') | |
try: | |
udb.check_username(usr.uid) | |
udb.check_userfree(usr.uid) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
if not interact: | |
return 0 | |
return 1 | |
def get_usertype(usr): | |
"""Get usertype.""" | |
usr.oldusertype = usr.usertype | |
if opt.usertype: | |
usr.usertype = opt.usertype | |
interact = 0 | |
else: | |
interact = 1 | |
print("Usertype must be specified. List of valid usertypes:\n") | |
for i in rbconfig.usertypes_list: | |
if opt.mode != 'renew' or i in rbconfig.usertypes_paying: | |
print(" %-12s %s" % (i, rbconfig.usertypes[i])) | |
print() | |
defans = usr.usertype or 'member' | |
while 1: | |
if interact: | |
usr.usertype = ask('Enter usertype', defans, hints = [i for i in rbconfig.usertypes_list if opt.mode != 'renew' or i in rbconfig.usertypes_paying]) | |
try: | |
if opt.mode == 'renew': | |
udb.check_renewal_usertype(usr.usertype) | |
else: | |
udb.check_usertype(usr.usertype) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_convert_usertype(usr): | |
"""Get usertype to convert to.""" | |
if opt.usertype: | |
usr.usertype = opt.usertype | |
interact = 0 | |
else: | |
interact = 1 | |
print("Conversion usertype must be specified. List of valid usertypes:\n") | |
for i in rbconfig.usertypes_list: | |
print(" %-12s %s" % (i, rbconfig.usertypes[i])) | |
print("\nSpecial committee positions (usertype is 'committe'):\n") | |
for i, j in list(rbconfig.convert_usertypes.items()): | |
print(" %-12s %s" % (i, j)) | |
print() | |
while 1: | |
if interact: | |
usr.usertype = ask('Enter conversion usertype', hints = list(rbconfig.usertypes_list) + list(rbconfig.convert_usertypes.keys())) | |
try: | |
udb.check_convert_usertype(usr.usertype) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_id(usr): | |
"""Get DCU ID.""" | |
if usr.usertype not in rbconfig.usertypes_dcu and opt.mode != 'update': | |
return | |
if opt.id != None: | |
usr.id = opt.id | |
interact = 0 | |
else: | |
interact = 1 | |
defans = usr.id | |
while 1: | |
if interact: | |
usr.id = ask('Enter student/staff id', defans, optional = opt.mode == 'update' or usr.usertype == 'committe') | |
try: | |
if usr.id: | |
usr.id = int(usr.id) | |
udb.check_id(usr) | |
except (ValueError, RBError) as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_name(usr, hints = None): | |
"""Get name (or account description).""" | |
if opt.cn: | |
usr.cn = opt.cn | |
interact = 0 | |
else: | |
interact = 1 | |
defans = usr.cn | |
while 1: | |
if interact: | |
usr.cn = ask("Enter name (or account description)", defans, hints = hints) | |
try: | |
udb.check_name(usr) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_mailuser(usr): | |
"""Ask wheter to mail user their details.""" | |
if opt.mailuser != None: | |
return | |
if not usr.usertype == 'reserved': | |
# By default mail them. | |
opt.mailuser = 1 | |
# If only adding database entry, don't mail. | |
if opt.mode == 'add' and opt.dbonly: | |
opt.mailuser = 0 | |
opt.mailuser = yesno('Mail account details to user', opt.mailuser) | |
else: | |
opt.mailuser = 0 | |
def get_createaccount(usr): | |
"""Ask if account should be created.""" | |
if opt.dbonly != None and opt.aconly != None: | |
return | |
if not yesno('Create account', 1): | |
opt.dbonly = 1 | |
opt.aconly = 0 | |
def get_setpasswd(usr): | |
"""Ask if new random password should be set.""" | |
if opt.setpasswd != None: | |
return | |
# XXX | |
#if opt.dbonly != None: | |
# opt.setpasswd = not opt.dbonly | |
# return | |
if opt.mode == 'renew': | |
opt.setpasswd = 0 | |
else: | |
opt.setpasswd = 1 | |
opt.setpasswd = yesno('Set new random password', opt.setpasswd) | |
def get_newbie(usr): | |
"""Get newbie boolean.""" | |
if opt.newbie != None: | |
usr.newbie = opt.newbie | |
return | |
usr.newbie = yesno('Flag as a new user', usr.newbie) | |
def get_years_paid(usr): | |
"""Get years paid.""" | |
if not usr.usertype in rbconfig.usertypes_paying and opt.mode != 'update': | |
return | |
if opt.yearsPaid != None: | |
usr.yearsPaid = opt.yearsPaid | |
interact = 0 | |
else: | |
interact = 1 | |
if opt.mode == 'add' and usr.yearsPaid == None: | |
usr.yearsPaid = 1 | |
defans = usr.yearsPaid | |
while 1: | |
if interact: | |
usr.yearsPaid = ask('Enter number of years paid', defans, optional = opt.mode == 'update' or usr.usertype in ('committe', 'guest')) | |
try: | |
if usr.yearsPaid: | |
usr.yearsPaid = int(usr.yearsPaid) | |
udb.check_years_paid(usr) | |
except (ValueError, RBError) as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_course(usr, hints = None): | |
"""Get DCU course.""" | |
if usr.usertype not in ('member', 'committee') and opt.mode != 'update': | |
return | |
if opt.course: | |
usr.course = opt.course | |
return | |
usr.course = ask('Enter course', usr.course, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
def get_year(usr, hints = None): | |
"""Get DCU year.""" | |
if usr.usertype not in ('member', 'committee') and opt.mode != 'update': | |
return | |
if opt.year != None: | |
usr.year = opt.year | |
return | |
usr.year = ask('Enter year', usr.year, optional = opt.mode == 'update' or usr.usertype == 'committe', hints = hints) | |
def get_email(usr, hints = None): | |
"""Get alternative email address.""" | |
if opt.altmail: | |
usr.altmail = opt.altmail | |
interact = 0 | |
else: | |
interact = 1 | |
defans = usr.altmail | |
while 1: | |
if interact: | |
usr.altmail = ask('Enter email', defans, hints = hints) | |
try: | |
udb.check_email(usr) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_updatedby(usr): | |
"""Get username of who is performing the action. | |
Uses LOGNAME environment variable by default unless it's 'root' in | |
which case no default is provided. There is no actual restriction on | |
using 'root', although its use (or any other generic username) is | |
strongly not recommended. | |
""" | |
if opt.updatedby: | |
usr.updatedby = opt.updatedby | |
interact = 0 | |
else: | |
interact = 1 | |
usr.updatedby = os.environ.get('LOGNAME') or os.environ.get('SU_FROM') | |
defans = usr.updatedby | |
while 1: | |
if interact: | |
usr.updatedby = ask('Enter who updated this user (give Unix username)', defans) | |
try: | |
udb.check_updatedby(usr.updatedby) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_birthday(usr): | |
"""Get (optional) birthday.""" | |
if not usr.usertype in rbconfig.usertypes_paying: | |
return | |
if opt.birthday != None: | |
usr.birthday = opt.birthday or None | |
interact = 0 | |
else: | |
interact = 1 | |
defans = usr.birthday | |
while 1: | |
if interact: | |
usr.birthday = ask("Enter birthday as 'YYYY-MM-DD'", defans, optional = 1) | |
try: | |
udb.check_birthday(usr) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_disuser_period(usr): | |
"""Get (optional) period of disuserment.""" | |
if len(opt.args) > 0: | |
usr.disuser_period = opt.args[0] | |
interact = 0 | |
else: | |
interact = 1 | |
while 1: | |
if interact: | |
usr.disuser_period = ask("If the account is to be automatically re-enabled, enter a valid at(1) timespec,\ne.g: '5pm', '12am + 2 weeks', 'now + 1 month' (see at man page).", optional = 1) | |
try: | |
udb.check_disuser_period(usr) | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_disuser_message(usr): | |
"""Get message to display when disusered user tries to log in.""" | |
file = os.path.join(rbconfig.dir_daft, usr.uid) | |
editor = os.environ.get('EDITOR', os.environ.get('VISUAL', 'vi')) | |
while 1: | |
if not os.path.isfile(file): | |
fd = open(file, "w") | |
fd.write("The contents of this file will be displayed when %s logs in.\nThe reason for disuserment should be placed here.\n" % (usr.uid)) | |
fd.close() | |
mtime = os.path.getmtime(file) | |
os.system("%s %s" % (acc.shquote(editor), acc.shquote(file))) | |
if not os.path.isfile(file) or not os.path.getsize(file) or mtime == os.path.getmtime(file): | |
if not rberror(RBWarningError('Unchanged disuser message file detected'), 1): | |
break | |
else: | |
break | |
os.chmod(file, 0o644) | |
def get_rrslog(): | |
"""Get name of RRS log file.""" | |
if len(opt.args) > 0 and opt.args[0]: | |
opt.rrslog = opt.args.pop(0) | |
interact = 0 | |
else: | |
interact = 1 | |
while 1: | |
if interact: | |
opt.rrslog = ask('Enter name of RRS logfile', rbconfig.file_rrslog) | |
try: | |
open(opt.rrslog, 'r').close() | |
except IOError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_pre_sync(): | |
"""Get name of pre_sync file.""" | |
if len(opt.args) > 0 and opt.args[0]: | |
opt.presync = opt.args.pop(0) | |
interact = 0 | |
else: | |
interact = 1 | |
while 1: | |
if interact: | |
opt.presync = ask('Enter name of pre_sync file', rbconfig.file_pre_sync) | |
try: | |
open(opt.presync, 'r').close() | |
except IOError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def get_shell(usr): | |
"""Get user shell.""" | |
if len(opt.args) > 0 and opt.args[0]: | |
usr.loginShell = opt.args.pop(0) | |
interact = 0 | |
else: | |
interact = 1 | |
defans = usr.loginShell | |
# XXX: gross hack to make dizer happy. preloads /etc/shells so we can | |
# pass it as hints below | |
# | |
udb.valid_shell('fuzz') | |
while 1: | |
if interact: | |
usr.loginShell = ask('Enter shell', defans, hints = [defans] + list(udb.valid_shells.keys())) | |
try: | |
# XXX: valid_shell should raise an exception? | |
if not udb.valid_shell(usr.loginShell): | |
raise RBWarningError('Not a valid shell') | |
except RBError as e: | |
if not rberror(e, interact): | |
break | |
else: | |
break | |
def check_paid(usr): | |
if usr.yearsPaid != None and usr.yearsPaid < 1 and not yesno('WARNING: This user has not renewed, continue?', 0): | |
raise RBFatalError('Aborting, user has not paid.') | |
#-----------------------------------------------------------------------------# | |
# ERROR HANDLING # | |
#-----------------------------------------------------------------------------# | |
def rberror(e, interactive = 0): | |
"""rberror(e[, interactive]) -> status | |
Handle (mostly) RBError exceptions. | |
Interactive: If e is a RBWarningError, prompt to override this error. | |
If overridden, return false. Otherwise and for all other errors, | |
return true. | |
Not interactive: If e is a RBWarningError and the override option was | |
set on the command line, return false. Otherwise and for all other | |
errors, exit the program. | |
""" | |
res = None | |
if not isinstance(e, RBError): | |
print("FATAL:", end=' ') | |
print(e) | |
if not isinstance(e, RBWarningError): | |
if interactive: | |
print() | |
return 1 | |
else: | |
if interactive: | |
print() | |
if yesno('Ignore this error?'): | |
opt.override = 1 | |
return 0 | |
else: | |
return 1 | |
elif opt.override: | |
print("[IGNORED]\n") | |
return 0 | |
# If we reach here we're not in interactive mode and the override | |
# option wasn't set, so all errors result in program exit. | |
# | |
print() | |
sys.exit(1) | |
def error(e, mesg = None): | |
"""error(e[, mesg]) | |
Handle general exceptions: prints the 'FATAL:' prefix, optional | |
message followed by the exception message. Exits program. | |
""" | |
print("FATAL: ", end=' ') | |
if mesg: | |
print(mesg) | |
print(e) | |
print() | |
sys.exit(1) | |
#-----------------------------------------------------------------------------# | |
# If module is called as script, run main() # | |
#-----------------------------------------------------------------------------# | |
if __name__ == "__main__": | |
main() (duplicate-code) | |
R: 1, 0: Similar lines in 2 files | |
==rrs:8 | |
==rrs:8 | |
import atexit | |
import cgi | |
import cgitb | |
import os | |
import time | |
import re | |
import sys | |
from xml.sax.saxutils import quoteattr | |
import ldap | |
# RedBrick modules | |
from rbuserdb import RBUserDB | |
from rbuser import RBUser | |
from rbopt import RBOpt | |
from rberror import RBError, RBWarningError, RBFatalError | |
#-----------------------------------------------------------------------------# | |
# DATA # | |
#-----------------------------------------------------------------------------# | |
__version__ = '$Revision: 1.6 $' | |
__author__ = 'Cillian Sharkey' | |
cmds = { | |
'card': 'Card reader interface', | |
'add': 'Add new user', | |
'delete': 'Delete user', | |
'renew': 'Renew user', | |
'update': 'Update user', | |
'rename': 'Rename user', | |
'convert': 'Convert user to new usertype', | |
'show': 'Show user information', | |
'freename': 'Check if a username is free', | |
'search': 'Search user and DCU databases', | |
'stats': 'Database statistics', | |
'log': 'Log of all actions' | |
} | |
cmds_list = ('card', 'add', 'delete', 'renew', 'update', 'rename', 'convert', 'show', 'freename', | |
'search', 'stats', 'log') | |
cmds_noform = { | |
'stats': 1, | |
'log': 1 | |
} | |
cmds_custom = { | |
'show': 1, | |
'search': 1 | |
} | |
fields = ( | |
('updatedby', 'Updated By', ('card', 'add', 'delete', 'renew', 'update', 'rename', 'convert')), | |
('cardid', 'DCU card id', ('card',)), | |
('uid', 'Username', ('card', 'add', 'delete', 'renew', 'update', 'rename', 'convert', 'show', | |
'search')), | |
('newuid', 'New username', ('renew', 'rename', 'freename')), | |
('newbie', 'New user?', ('update',)), | |
('birthday', 'Birthday', ('add', 'renew', 'update')), | |
('id', 'DCU ID', ('add', 'renew', 'update', 'search')), | |
('usertype', 'Usertype', ('add', 'renew', 'convert')), | |
('cn', 'Name', ('add', 'renew', 'update', 'search')), | |
('altmail', 'Email', ('add', 'renew', 'update')), | |
('course', 'Course Code', ('add', 'renew', 'update')), | |
('year', 'Course Year', ('add', 'renew', 'update')), | |
('yearsPaid', 'Years Paid', ('add', 'renew', 'update')), | |
('setpasswd', 'Set new password?', ('renew',)), | |
('override', 'Override errors?', ('card', 'add', 'renew', 'update', 'rename')), | |
('dummyid', "Use 'dummy' ID?", ('card',)), | |
) | |
# Optional side note for form fields. For a particular mode only, use | |
# "fieldname.mode". | |
# | |
fields_note = { | |
'updatedby': 'your RedBrick username', | |
'birthday': 'DD-MM-YYYY', | |
'year': "'X' for exchange students", | |
'yearsPaid': '5 is only for associates', | |
'dummyid': 'New members only', | |
'uid.search': 'Search user database', | |
'id.search': 'Search user & DCU databases', | |
'cn.search': 'Search user & DCU databases' | |
} | |
# Fields that are simple yes/no choices. These are implemented using radio | |
# dialogs instead of a checkbox, as they allow neither yes nor no to be set | |
# (i.e. None). | |
# | |
fields_yesno = { | |
'setpasswd': 1, | |
'override': 1, | |
'dummyid': 1, | |
'newbie': 1 | |
} | |
# HTML for custom form input fields. | |
# | |
fields_input = { | |
'cardid': 'class=fixed size=18 maxlength=16', | |
'cn': 'size=30', | |
'altmail': 'size=30', | |
'course': 'size=10 maxlength=50', | |
'year': 'size=10 maxlength=10' | |
} | |
# Global variables. | |
# | |
usr = RBUser() | |
opt = RBOpt() | |
udb = form = None # Initalised later in main() | |
okay = 0 | |
start_done = end_done = 0 | |
error_string = notice_string = okay_string = '' | |
#-----------------------------------------------------------------------------# | |
# MAIN # | |
#-----------------------------------------------------------------------------# | |
def main(): | |
"""Program entry function.""" | |
# XXX: Stupid Apache on shrapnel has TZ set to US/Eastern, no idea why! | |
os.environ['TZ'] = 'Eire' | |
print("Content-type: text/html") | |
print() | |
atexit.register(shutdown) | |
# Sets up an exception handler for uncaught exceptions and saves | |
# traceback information locally. | |
# | |
cgitb.enable(logdir='%s/tracebacks' % os.getcwd()) | |
global form | |
form = cgi.FieldStorage() | |
opt.mode = form.getfirst('mode') | |
if opt.mode not in cmds: | |
opt.mode = 'card' | |
opt.action = form.getfirst('action') | |
#XXX remove usr.override | |
#usr.override = opt.override = form.getfirst('override') == '1' | |
opt.override = form.getfirst('override') == '1' | |
# Start HTML now only for modes that print output *before* html_form is | |
# called (which calls start_html itself). We delay the printing of the | |
# header for all other modes as mode switching may occur (e.g. | |
# cardid <-> add/renew). | |
# | |
if opt.mode in cmds_noform or (opt.mode in cmds_custom and opt.action): | |
html_start() | |
global udb | |
udb = RBUserDB() | |
udb.setopt(opt) | |
# Open database and call function for specific command only if action | |
# is required or the command needs no user input (i.e. no blank form | |
# stage). | |
# | |
if opt.mode in cmds_noform or opt.action: | |
try: | |
udb.connect() | |
except ldap.LDAPError as err: | |
error(err, 'Could not connect to user database') | |
# not reached | |
try: | |
eval(opt.mode + '()') | |
except (ldap.LDAPError, RBError) as err: | |
error(err) | |
# not reached | |
html_form() | |
sys.exit(0) | |
def shutdown(): | |
"""Cleanup function registered with atexit.""" | |
html_end() | |
if udb: | |
udb.close() | |
def html_start(): | |
"""Start HTML output.""" | |
global start_done | |
if start_done: | |
return | |
start_done = 1 | |
print(\ | |
"""<html> | |
<head> | |
<title>RedBrick Registration System v3.0 - %s</title> | |
<link rel="stylesheet" href="common.css" type="text/css"> | |
<script language="JavaScript" type="text/javascript"> | |
<!-- | |
function page_load () { | |
if (document.mainform) { | |
f = document.mainform; | |
} else { | |
return; | |
} | |
if (f.updatedby && f.updatedby.value.length == 0) { | |
f.updatedby.focus(); | |
} else if (f.cardid && f.cardid.value.length == 0) { | |
f.cardid.focus(); | |
} else if (f.uid && f.uid.value.length == 0) { | |
f.uid.focus(); | |
} else if (f.newuid && f.newuid.value.length == 0) { | |
f.newuid.focus(); | |
} else if (f.cardid) { | |
f.cardid.focus(); | |
} else if (f.uid) { | |
f.uid.focus(); | |
} else if (f.newuid) { | |
f.newuid.focus(); | |
} | |
} | |
function radio_value (r) { | |
for (var i = 0; i < r.length; i++) { | |
if (r[i].checked == true) { | |
return (r[i].value); | |
} | |
} | |
return (null); | |
} | |
function check_form (f) { | |
if (f.updatedby && f.updatedby.value.length == 0) { | |
alert("updatedby must be given"); | |
f.updatedby.focus(); | |
return false; | |
} | |
return true; | |
} | |
// --> | |
</script> | |
</head> | |
<body text=black bgcolor=white onLoad="javascript:page_load()"> | |
<div id=top>RedBrick Registration System v3.0</div> | |
<div id=menu> | |
<form name=menuform action='rrs.cgi' method=get>""" % opt.mode.capitalize()) | |
if form.getfirst('updatedby'): | |
print("<input type=hidden name=updatedby value=%s>" % quoteattr(form.getfirst('updatedby') | |
or '')) | |
for i in cmds_list: | |
print("<input id=button type=submit name=mode value=%s> " % i) | |
print(\ | |
"""</form> | |
</div> | |
<div id=top>%s</div> | |
<div id=main> | |
""" % cmds[opt.mode]) | |
def html_form(): | |
"""Output HTML form for current mode.""" | |
global usr | |
html_start() | |
if notice_string or error_string or okay_string: | |
print("<table align=center id=msgs><tr><td>") | |
if error_string: | |
print("<span id=warn>%s</span>" % error_string.replace('\n', '<br>\n')) | |
if notice_string: | |
print("<span id=notice>%s</span>" % notice_string.replace('\n', '<br>\n')) | |
if okay_string: | |
print("<span id=okay>%s</span>" % okay_string.replace('\n', '<br>\n')) | |
print("</td></tr></table>") | |
# Modes that never use a form or don't want a form when action has been | |
# requested and successful. | |
# | |
if opt.mode in cmds_noform or (opt.mode in cmds_custom and opt.action and okay): | |
return | |
if okay: | |
# Need a blank form, so create new user but keep updatedby set. | |
# Set override & setpassword options back to default (off). | |
# | |
usr = RBUser(updatedby=form.getfirst('updatedby')) | |
opt.override = 0 | |
opt.setpasswd = 0 | |
else: | |
# We want to preserve the form input so fill in as much data on | |
# the form as possible. | |
# | |
for k in list(form.keys()): | |
if hasattr(usr, k) and getattr(usr, k) is None: | |
setattr(usr, k, form.getfirst(k)) | |
print(\ | |
"""<form name=mainform onSubmit="javascript:return check_form(this)" action="rrs.cgi" method=get> | |
<input type=hidden name=mode value=%s> | |
<input type=hidden name=action value=1>""" % opt.mode) | |
print('<table align=center class=main border=0 cellpadding=1 cellspacing=5>') | |
for field, desc, modes in fields: | |
if opt.mode not in modes: | |
# If updatedby isn't an actual visible field on the | |
# form, add it as a hidden field so its value gets | |
# passed on. | |
# | |
if field == 'updatedby' and form.getfirst('updatedby'): | |
print('<input type=hidden name=updatedby value=%s>' % | |
quoteattr(form.getfirst('updatedby') or '')) | |
else: | |
usrval = '' | |
if hasattr(usr, field) and getattr(usr, field) != None: | |
usrval = getattr(usr, field) | |
if field == 'override': | |
usrval = opt.override | |
elif field == 'cardid' and not usrval and usr.id: | |
usrval = usr.id | |
print('<tr>') | |
print(' <td class=side>%s</td>' % desc) | |
print(' <td>', end=' ') | |
if field in fields_input: | |
print('<input %s name=%s value=%s>' % (fields_input[field], field, quoteattr(str(usrval)))) | |
elif field in fields_yesno: | |
print('<input name=%s type=radio value=1%s> Yes <input name=%s type=radio value=0%s> No' % (field, usrval == 1 and ' checked' or '', field, usrval == 0 and ' checked' or '')) | |
elif field == 'usertype': | |
# Show default usertype of member if none set. | |
if not usr.usertype: | |
usr.usertype = 'member' | |
print('<select name=usertype>') | |
for i in rbconfig.usertypes_paying: | |
print('<option value=%s' % i, end=' ') | |
if usr.usertype == i: | |
print(' selected', end=' ') | |
print('>', i.capitalize()) | |
print('</select>') | |
elif field == 'birthday': | |
if usr.birthday: | |
res = re.search(r'^(\d{4})-(\d{2})-(\d{2})', usr.birthday) | |
if res: | |
usr.bday = res.group(3) | |
usr.bmonth = res.group(2) | |
usr.byear = res.group(1) | |
print("<input size=2 maxlength=2 name=bday value='%s'>-<input size=2 maxlength=2 name=bmonth value='%s'>-<input size=4 maxlength=4 name=byear value='%s'>" % (usr.bday or '', usr.bmonth or '', usr.byear or '')) | |
else: | |
print("<input class=fixed size=10 maxlength=8 name=%s value=%s" % (field, quoteattr(str(usrval))), end=' ') | |
if field == 'uid' and usr.uid and opt.mode in ('renew', 'update'): | |
print(' readonly', end=' ') | |
print('>') | |
print('</td>') | |
print(' <td><span id=note>', end=' ') | |
if '%s.%s' % (field, opt.mode) in fields_note: | |
print(fields_note['%s.%s' % (field, opt.mode)], end=' ') | |
elif field in fields_note: | |
print(fields_note[field], end=' ') | |
print('</span></td>') | |
print('</tr>') | |
print("""</table> | |
<p><input id=button type=submit value='%s >>'></p> | |
</form>""" % opt.mode.capitalize()) | |
def html_end(): | |
"""Finish HTML output.""" | |
global end_done | |
if end_done: | |
return | |
end_done = 1 | |
print("""</div> | |
</body> | |
</html>""") | |
#-----------------------------------------------------------------------------# | |
# MAIN FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def card(): | |
"""Process input from card reader form. Mode will be switched to add or | |
renew as appropriate if there were no problems with user input.""" | |
get_updatedby(usr) | |
get_cardid(usr) | |
newmode = None | |
# We have an ID, is it a newbie or a renewal? | |
# | |
if usr.id != None: | |
try: | |
udb.check_user_byid(usr.id) | |
except RBError: | |
# Doesn't exist, must be new user. | |
newmode = 'add' | |
else: | |
# Exists, must be renewal. | |
newmode = 'renew' | |
elif form.getfirst('dummyid'): | |
get_dummyid(usr) | |
newmode = 'add' | |
elif form.getfirst('uid'): | |
usr.uid = form.getfirst('uid') | |
udb.check_username(usr.uid) | |
try: | |
udb.check_user_byname(usr.uid) | |
except RBError: | |
# Doesn't exist, must be new user. | |
newmode = 'add' | |
else: | |
# Exists, must be renewal. | |
newmode = 'renew' | |
else: | |
raise RBFatalError("DCU Card ID, username or dummy ID must be given") | |
if newmode == 'add': | |
if usr.id != None: | |
udb.get_userinfo_new(usr) | |
udb.get_userdefaults_new(usr) | |
elif newmode == 'renew': | |
curusr = RBUser() | |
udb.get_userinfo_renew(usr, curusr, override = 1) | |
udb.check_unpaid(curusr) | |
udb.get_userdefaults_renew(usr) | |
if newmode: | |
opt.mode = newmode | |
def add(): | |
"""Add a new user.""" | |
global okay, okay_string | |
get_updatedby(usr) | |
get_usertype(usr) | |
get_newusername(usr) | |
get_id(usr) | |
udb.get_userinfo_new(usr) | |
udb.get_userdefaults_new(usr) | |
get_name(usr) | |
get_email(usr) | |
get_course(usr) | |
get_year(usr) | |
get_years_paid(usr) | |
get_birthday(usr) | |
# Add user to database. | |
# | |
udb.add(usr) | |
# If we reached here, operation was successful, so show result of | |
# operation, log it and switch back to card mode. | |
# | |
okay = 1 | |
okay_string += 'OKAY: User added: %s %s (%s)' % (usr.usertype, usr.uid, usr.cn) | |
rrs_log_add('add:%s:%s:%s:%s:%s:%s:%s:%s:%s' % | |
(usr.uid, usr.usertype, usr.id != None and usr.id or '', usr.cn, usr.course or '', | |
usr.year or '', usr.altmail, usr.birthday or '', usr.yearsPaid)) | |
opt.mode = 'card' | |
def delete(): | |
"""Delete user.""" | |
global okay, okay_string | |
get_updatedby(usr) | |
get_username(usr) | |
udb.delete(usr) | |
okay = 1 | |
okay_string += 'OKAY: User deleted: %s\n' % usr.uid | |
rrs_log_add('delete:%s' % (usr.uid)) | |
def renew(): | |
"""Renew user.""" | |
global okay, okay_string | |
newusr = RBUser() | |
curusr = RBUser() | |
get_updatedby(usr) | |
get_username(usr) | |
get_newusername(newusr) | |
udb.get_userinfo_renew(usr, curusr) | |
udb.get_userdefaults_renew(usr) | |
get_setpasswd(usr) | |
get_usertype(usr) | |
get_id(usr) | |
udb.get_userinfo_renew(usr) | |
get_name(usr) | |
get_email(usr) | |
get_course(usr) | |
get_year(usr) | |
get_years_paid(usr) | |
get_birthday(usr) | |
udb.renew(usr) | |
okay_string += 'OKAY: User renewed: %s %s%s\n' % (usr.oldusertype, usr.uid, opt.setpasswd and | |
' [new password set]' or '') | |
rrs_log_add('renew:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s' % | |
(usr.uid, newusr.uid or '', opt.setpasswd and 1 or 0, usr.usertype, usr.id != None | |
and usr.id or '', usr.cn, usr.course or '', usr.year != None and usr.year or '', | |
usr.altmail, usr.birthday or '', usr.yearsPaid)) | |
# NOTE: We don't actually generate/set a password here, just flag it in | |
# the 'transaction log' so that sync_renew in useradm will set it | |
# instead. | |
# NOTE: If a renewal changed usertype, convert it and log it. | |
# sync_renew in useradm will detect the usertype change and convert the | |
# account. | |
# | |
if usr.oldusertype != usr.usertype: | |
udb.convert(curusr, usr) | |
okay_string += 'OKAY: User converted: %s -> %s\n' % (usr.uid, usr.usertype) | |
rrs_log_add('convert:%s:%s' % (usr.uid, usr.usertype)) | |
# NOTE: If new username is given, rename database entry and log it. | |
# sync_rename in useradm will use this log entry to rename the account | |
# but only if it's a rename of an existing user only (i.e newbie is | |
# false). | |
# | |
if newusr.uid: | |
udb.rename(usr, newusr) | |
okay_string += 'OKAY: User renamed: %s -> %s\n' % (usr.uid, newusr.uid) | |
rrs_log_add('rename-%s:%s:%s' % (usr.newbie and 'new' or 'existing', usr.uid, newusr.uid)) | |
okay = 1 | |
opt.mode = 'card' | |
def update(): | |
"""Update user.""" | |
global okay, okay_string | |
get_updatedby(usr) | |
get_username(usr) | |
udb.get_user_byname(usr) | |
get_newbie(usr) | |
get_id(usr) | |
get_name(usr) | |
get_email(usr) | |
get_course(usr) | |
get_year(usr) | |
get_years_paid(usr) | |
get_birthday(usr) | |
udb.update(usr) | |
okay = 1 | |
okay_string += 'OKAY: User updated: %s\n' % usr.uid | |
rrs_log_add('update:%s:%s:%s:%s:%s:%s:%s:%s:%s' % (usr.uid, usr.newbie and 1 or 0, usr.id != None and usr.id or '', usr.cn, usr.course or '', usr.year != None and usr.year or '', usr.altmail, usr.birthday or '', usr.yearsPaid)) | |
def rename(): | |
"""Rename user.""" | |
global okay, okay_string | |
newusr = RBUser() | |
get_updatedby(usr) | |
get_username(usr) | |
udb.get_user_byname(usr) | |
get_newusername(newusr) | |
udb.rename(usr, newusr) | |
okay = 1 | |
okay_string += 'OKAY: User renamed: %s -> %s\n' % (usr.uid, newusr.uid) | |
rrs_log_add('rename-%s:%s:%s' % (usr.newbie and 'new' or 'existing', usr.uid, newusr.uid)) | |
def convert(): | |
"""Convert user.""" | |
global okay, okay_string | |
newusr = RBUser() | |
get_updatedby(usr) | |
get_username(usr) | |
get_usertype(newusr) | |
udb.convert(usr, newusr) | |
okay = 1 | |
okay_string += 'OKAY: User converted: %s -> %s\n' % (usr.uid, newusr.usertype) | |
rrs_log_add('convert:%s:%s' % (usr.uid, newusr.usertype)) | |
def show(): | |
"""Show user's details.""" | |
global okay | |
get_username(usr) | |
udb.get_user_byname(usr) | |
print('<pre>') | |
udb.show(usr) | |
print('</pre>') | |
okay = 1 | |
def freename(): | |
"""Check if a username is free.""" | |
global okay_string | |
get_newusername(usr) | |
if usr.uid: | |
okay_string += "OKAY: Username '%s' is free.\n" % usr.uid | |
def search(): | |
"""Search user and/or DCU databases.""" | |
global okay | |
if form.getfirst('uid'): | |
uid = form.getfirst('uid') | |
res = udb.search_users_byusername(uid) | |
print("<p align=center>User database search for username '%s' - %d match%s</p>" % (uid, len(res), len(res) != 1 and 'es' or '')) | |
show_search_results(res) | |
okay = 1 | |
elif 'id' in form or 'cn' in form: | |
id = form.getfirst('id') | |
cn = form.getfirst('cn') | |
if id != None: | |
res = udb.search_users_byid(id) | |
print("<p align=center>User database search for ID '%s' - %d match%s</p>" % (id, len(res), len(res) != 1 and 'es' or '')) | |
else: | |
res = udb.search_users_byname(cn) | |
print("<p align=center>User database search for name '%s' - %d match%s</p>" % (cn, len(res), len(res) != 1 and 'es' or '')) | |
show_search_results(res) | |
if id != None: | |
res = udb.search_dcu_byid(id) | |
print("<p align=center>DCU database search for ID '%s' - %d match%s</p>" % (id, len(res), len(res) != 1 and 'es' or '')) | |
else: | |
res = udb.search_dcu_byname(cn) | |
print("<p align=center>DCU database search for name '%s' - %d match%s</p>" % (cn, len(res), len(res) != 1 and 'es' or '')) | |
show_search_results(res) | |
okay = 1 | |
else: | |
raise RBFatalError('No search term given!') | |
def show_search_results(res): | |
"""Actual routine to display search results.""" | |
if res: | |
print('<table align=center class=search>') | |
print('<tr><td></td><td class=top>Username</td><td class=top>Usertype</td><td class=top>Id</td><td class=top>Name</td><td class=top>Course</td><td class=top>Year</td><td class=top>Email</td></tr>') | |
for uid, usertype, id, cn, course, year, altmail in res: | |
print('<tr><td class=button>', end=' ') | |
if uid: | |
print('<form action=rrs.cgi method=get><input type=hidden name=updatedby value=%s><input type=hidden name=uid value=%s><input type=hidden name=action value=1><input id=button type=submit name=mode value=show></form>' % (quoteattr(form.getfirst('updatedby') or ''), uid), end=' ') | |
print('</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (uid or '-', usertype or '-', id or '-', cn, course or '-', year or '-', altmail)) | |
print('</table>') | |
def stats(): | |
"""Show database statistics.""" | |
print("<pre>") | |
udb.stats() | |
print("</pre>") | |
def log(): | |
"""Show contents of rrs log file.""" | |
try: | |
fd = open('rrs.log', 'r') | |
except IOError as e: | |
error(e, 'Could not open rrs.log') | |
print('<pre>\n') | |
if os.path.getsize('rrs.log') == 0: | |
print('Logfile is empty.') | |
else: | |
for line in fd: | |
print(line, end=' ') | |
print('</pre>') | |
fd.close() | |
#-----------------------------------------------------------------------------# | |
# GET USER DATA FUNCTIONS # | |
#-----------------------------------------------------------------------------# | |
def get_username(usr): | |
"""Get an existing username.""" | |
if form.getfirst('uid'): | |
usr.uid = form.getfirst('uid') | |
else: | |
raise RBFatalError('Username must be given') | |
udb.check_username(usr.uid) | |
udb.check_user_byname(usr.uid) | |
def get_newusername(usr): | |
"""Get a new (free) username.""" | |
if opt.mode == 'add': | |
if form.getfirst('uid'): | |
usr.uid = form.getfirst('uid') | |
else: | |
if form.getfirst('newuid'): | |
usr.uid = form.getfirst('newuid') | |
# New username is optional for renewals but compulsory for all other | |
# modes that require it (add, rename, freename). | |
# | |
if opt.mode == 'renew' and not usr.uid: | |
return | |
if not usr.uid: | |
raise RBFatalError('New username must be given') | |
try: | |
udb.check_username(usr.uid) | |
udb.check_userfree(usr.uid) | |
except RBWarningError as e: | |
error(e) | |
def get_cardid(usr): | |
"""Set usr.id to DCU ID number in cardid field. | |
The ID will either be the 8 digit number when entered manually or the | |
13 digit code produced by barcode and magnetic readers of the form | |
xxIDNUMBERnnn with possible start and/or end sentinel characters such | |
as ';' or '?'. Some readers will output a code number at the start, | |
(to indicate the type of barcode or something) so we assume the 13 digit | |
number is at the end (i.e. right-hand side) of the string. | |
If invalid input is given, raises RBFatalError. | |
NOTE: It is up to the caller to check if usr.id has been set, | |
get_cardid does not require it to be set. | |
""" | |
usr.id = form.getfirst('cardid') | |
if usr.id != None: | |
res = re.search(r'\d{2}(\d{8})\d{3}\D*$', usr.id) | |
if res: | |
usr.id = int(res.group(1)) | |
return | |
res = re.search(r'^(\d{8})$', usr.id) | |
if res: | |
usr.id = int(usr.id) | |
return | |
raise RBFatalError('Invalid ID number/card reader input') | |
def get_updatedby(usr): | |
"""Get username of who is performing the action.""" | |
if form.getfirst('updatedby'): | |
usr.updatedby = form.getfirst('updatedby') | |
else: | |
raise RBFatalError('Updated by must be given') | |
if usr.updatedby == 'root': | |
raise RBFatalError('root not allowed for updatedby') | |
udb.check_updatedby(usr.updatedby) | |
def get_usertype(usr): | |
"""Get usertype.""" | |
usr.oldusertype = usr.usertype | |
if form.getfirst('usertype'): | |
usr.usertype = form.getfirst('usertype') | |
else: | |
raise RBFatalError('Usertype must be given') | |
udb.check_usertype(usr.usertype) | |
def get_id(usr): | |
"""Get DCU ID.""" | |
if usr.usertype in rbconfig.usertypes_dcu: | |
if form.getfirst('id'): | |
usr.id = int(form.getfirst('id')) | |
else: | |
raise RBFatalError('ID must be given') | |
udb.check_id(usr) | |
def get_dummyid(usr): | |
"""Get 'dummy' DCU ID.""" | |
if form.getfirst('dummyid'): | |
udb.get_dummyid(usr) | |
#XXX remove usr.override | |
#usr.override = opt.override = 1 | |
opt.override = 1 | |
def get_name(usr): | |
"""Get name.""" | |
if form.getfirst('cn'): | |
usr.cn = form.getfirst('cn') | |
else: | |
raise RBFatalError('Name must be given') | |
udb.check_name(usr) | |
def get_years_paid(usr): | |
"""Get years paid.""" | |
if not usr.usertype in rbconfig.usertypes_paying: | |
return | |
if form.getfirst('yearsPaid'): | |
usr.yearsPaid = int(form.getfirst('yearsPaid')) | |
else: | |
raise RBFatalError('Years paid must be given') | |
udb.check_years_paid(usr) | |
def get_course(usr): | |
"""Get DCU course.""" | |
if not usr.usertype in ('member', 'committe'): | |
return | |
if form.getfirst('course'): | |
usr.course = form.getfirst('course') | |
else: | |
raise RBFatalError('Course must be given') | |
def get_year(usr): | |
"""Get DCU year.""" | |
if not usr.usertype in ('member', 'committe'): | |
return | |
if form.getfirst('year'): | |
usr.year = form.getfirst('year') | |
else: | |
raise RBFatalError('Year must be given') | |
def get_email(usr): | |
"""Get alternative email address.""" | |
if form.getfirst('altmail'): | |
usr.altmail = form.getfirst('altmail') | |
else: | |
raise RBFatalError('Email must be given') | |
try: | |
udb.check_email(usr) | |
except RBWarningError as e: | |
error(e) | |
def get_birthday(usr): | |
"""Get (optional) birthday.""" | |
if form.getfirst('byear') or form.getfirst('bmonth') or form.getfirst('bday'): | |
if not (form.getfirst('byear') and form.getfirst('bmonth') and form.getfirst('bday')): | |
raise RBFatalError('Incomplete birthday given') | |
try: | |
usr.birthday = '%.4d-%0.2d-%0.2d' % (int(form.getfirst('byear')), int(form.getfirst('bmonth')), int(form.getfirst('bday'))) | |
except ValueError: | |
raise RBFatalError('Invalid birthday given') | |
udb.check_birthday(usr) | |
def get_setpasswd(usr): | |
"""Get set new password boolean.""" | |
if form.getfirst('setpasswd') != None: | |
opt.setpasswd = form.getfirst('setpasswd') == '1' | |
def get_newbie(usr): | |
"""Get newbie boolean.""" | |
if form.getfirst('newbie') != None: | |
usr.newbie = form.getfirst('newbie') == '1' | |
#-----------------------------------------------------------------------------# | |
# LOGFILE HANDLING # | |
#-----------------------------------------------------------------------------# | |
def rrs_log_add(msg): | |
"""Add an entry for the current command to the logfile.""" | |
if not msg: | |
msg = "%s:EMPTY MESSAGE" % opt.mode | |
msg = "%s:%s:%s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), usr.updatedby, msg) | |
try: | |
fd = open('rrs.log', 'a') | |
except IOError as err: | |
error('Could not write to rrs.log', err) | |
print(msg, file=fd) | |
fd.close() | |
#-----------------------------------------------------------------------------# | |
# ERROR HANDLING # | |
#-----------------------------------------------------------------------------# | |
def error(err, mesg=''): | |
"""Handle (mainly) RBError exceptions.""" | |
if not isinstance(err, RBError): | |
prefix = 'FATAL: %s' % (mesg and mesg + '\n' or '') | |
elif isinstance(err, RBWarningError) and opt.override: | |
prefix = 'IGNORED: ' | |
else: | |
prefix = '' | |
global error_string | |
error_string += '%s%s\n' % (prefix, err) | |
if isinstance(err, RBWarningError) and opt.override: | |
return | |
# If we reach here the override option wasn't set, so all errors result | |
# in program exit. | |
# | |
html_form() | |
sys.exit(1) | |
#-----------------------------------------------------------------------------# | |
# If module is called as script, run main() # | |
#-----------------------------------------------------------------------------# | |
if __name__ == "__main__": | |
main() (duplicate-code) | |
R: 1, 0: Similar lines in 8 files | |
==rrs:456 | |
==rrs:456 | |
==rrs:512 | |
==rrs:512 | |
==rrs:564 | |
==rrs:564 | |
==useradm:318 | |
==useradm:318 | |
get_name(usr) | |
get_email(usr) | |
get_course(usr) | |
get_year(usr) | |
get_years_paid(usr) | |
get_birthday(usr) | |
(duplicate-code) | |
------------------------------------------------------------------ | |
Your code has been rated at 4.20/10 (previous run: 4.20/10, +0.00) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment