Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
accountmanager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sucs
accountmanager
Commits
16b2bfd8
Commit
16b2bfd8
authored
6 years ago
by
Imran Hussain
Browse files
Options
Downloads
Patches
Plain Diff
Inital dump of the sucs account manger
Can generate some useful stats and list everybody so far
parent
6a8bc5db
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sucsam.py
+111
-0
111 additions, 0 deletions
sucsam.py
with
111 additions
and
0 deletions
sucsam.py
0 → 100644
+
111
−
0
View file @
16b2bfd8
import
os
import
sys
import
readline
import
psycopg2
def
mainMenu
():
print
(
"
\n
Please choose an option
"
)
print
(
"
[h] Diplay some help
"
)
print
(
"
[qs] View quick stats of all accounts
"
)
print
(
"
[la] View a list of ALL accounts
"
)
print
(
"
[q] Quit
"
)
option
=
input
(
"
Option:
"
)
print
(
"
\n
"
)
if
(
option
==
"
h
"
):
print
(
"
help text comming soon
"
)
mainMenu
()
elif
(
option
==
"
q
"
):
DBconn
.
close
()
sys
.
exit
(
0
)
elif
(
option
==
"
qs
"
):
quickStats
()
mainMenu
()
elif
(
option
==
"
la
"
):
listUsers
()
mainMenu
()
else
:
mainMenu
()
def
quickStats
():
print
(
"
There are:
"
)
print
(
str
(
len
(
students
))
+
"
Students
"
)
paidyears
=
{}
for
item
in
students
:
paidyears
[
item
[
1
]]
=
paidyears
.
get
(
item
[
1
],
0
)
+
1
for
item
in
sorted
(
paidyears
):
print
(
"
-
"
+
str
(
paidyears
[
item
])
+
"
:
"
+
str
(
item
))
print
(
str
(
len
(
societies
))
+
"
Societies
"
)
paidyears
=
{}
for
item
in
societies
:
paidyears
[
item
[
1
]]
=
paidyears
.
get
(
item
[
1
],
0
)
+
1
for
item
in
sorted
(
paidyears
):
print
(
"
-
"
+
str
(
paidyears
[
item
])
+
"
:
"
+
str
(
item
))
print
(
str
(
len
(
associates
))
+
"
Associates
"
)
paidyears
=
{}
for
item
in
associates
:
paidyears
[
item
[
1
]]
=
paidyears
.
get
(
item
[
1
],
0
)
+
1
for
item
in
sorted
(
paidyears
):
print
(
"
-
"
+
str
(
paidyears
[
item
])
+
"
:
"
+
str
(
item
))
print
(
str
(
len
(
lifers
))
+
"
Lifers
"
)
print
(
str
(
len
(
hons
))
+
"
Honoary
"
)
def
listUsers
():
print
(
"
Students:
"
)
for
student
in
students
:
print
(
str
(
student
[
0
])
+
"
(
"
+
str
(
student
[
1
])
+
"
)
"
)
print
(
"
\n
Societies:
"
)
for
soc
in
societies
:
print
(
str
(
soc
[
0
])
+
"
(
"
+
str
(
soc
[
1
])
+
"
)
"
)
print
(
"
\n
Associates:
"
)
for
associate
in
associates
:
print
(
str
(
associate
[
0
])
+
"
(
"
+
str
(
associate
[
1
])
+
"
)
"
)
print
(
"
\n
Lifers:
"
)
for
life
in
lifers
:
print
(
str
(
life
[
0
])
+
"
(
"
+
str
(
life
[
1
])
+
"
)
"
)
print
(
"
\n
Honoary:
"
)
for
hon
in
hons
:
print
(
str
(
hon
[
0
])
+
"
(
"
+
str
(
hon
[
1
])
+
"
)
"
)
### MAIN ###
if
(
os
.
geteuid
()
==
0
):
print
(
"
Don
'
t run this as root!
"
)
sys
.
exit
(
1
)
#This tool was written for python *3*
#but doesn't mean we can't support 2 as well :)
try
:
input
=
raw_input
except
NameError
:
pass
#try and connect to the db
try
:
DBconn
=
psycopg2
.
connect
(
database
=
"
sucs
"
)
except
:
print
(
"
Can
'
t connect to the SUCS DB, suicidng!
"
)
sys
.
exit
(
2
)
#store some data from to db to operate on
cur
=
DBconn
.
cursor
()
cur
.
execute
(
"
SELECT username,paid from members WHERE type=1 ORDER BY paid
"
)
students
=
cur
.
fetchall
()
cur
.
execute
(
"
SELECT username,paid from members WHERE type=2 ORDER BY paid
"
)
societies
=
cur
.
fetchall
()
cur
.
execute
(
"
SELECT username,paid from members WHERE type=5 ORDER BY paid
"
)
associates
=
cur
.
fetchall
()
cur
.
execute
(
"
SELECT username,paid from members WHERE type=4 ORDER BY username
"
)
lifers
=
cur
.
fetchall
()
cur
.
execute
(
"
SELECT username,paid from members WHERE type=3 ORDER BY username
"
)
hons
=
cur
.
fetchall
()
cur
.
close
()
print
(
"
Welcome to the SUCS Account Manager!
"
)
mainMenu
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment