add parseGroup
This commit is contained in:
parent
dfa4a33df4
commit
b61c088e58
3 changed files with 39 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
from datetime import date, timedelta
|
||||
import fedmsg.meta
|
||||
import fedmsg
|
||||
|
|
@ -275,4 +276,3 @@ def generate_graph(output_json, title, category=None, gtype=None):
|
|||
show_gource(output_json)
|
||||
else:
|
||||
print("[!] That output mode is not supported! Check README for help.")
|
||||
|
||||
|
|
|
|||
35
parseGroup.py
Normal file
35
parseGroup.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import ConfigParser
|
||||
import os.path
|
||||
from fedora.client import AccountSystem, AuthError
|
||||
|
||||
class GroupParser:
|
||||
|
||||
def __init__(self):
|
||||
self.username = None
|
||||
self.password = None
|
||||
self.config = ConfigParser.RawConfigParser()
|
||||
try:
|
||||
self.config.read('fas_credentials.cfg')
|
||||
self.username = self.config.get('fas', 'username').strip('\'')
|
||||
self.password = self.config.get('fas', 'password').strip('\'')
|
||||
self.check_config()
|
||||
except:
|
||||
print("[*] Invalid / Missing Configuration file.")
|
||||
def check_config(self):
|
||||
if self.username.strip('\'') == 'FAS_USERNAME_HERE':
|
||||
print("[*] Please enter FAS credentials in fas_credentials.cfg")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def group_users(self, group_name):
|
||||
group_json = dict()
|
||||
account = AccountSystem(username=self.username,
|
||||
password=self.password)
|
||||
try:
|
||||
group_json = account.group_members(group_name)
|
||||
except AuthError:
|
||||
print("[*] Invalid Username / Password")
|
||||
return 1
|
||||
userlist = [user_desc.values()[0] for user_desc in group_json]
|
||||
return userlist
|
||||
3
stats.py
3
stats.py
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import fedmsg
|
||||
import fedmsg.meta
|
||||
import calendar
|
||||
|
|
@ -136,4 +138,3 @@ def return_interactions(subcategories):
|
|||
for key in interaction_dict:
|
||||
interaction_dict[key] = Counter(interaction_dict[key])
|
||||
return interaction_dict
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue