diff options
Diffstat (limited to 'projects/devdashboard/original_scripts')
9 files changed, 604 insertions, 0 deletions
diff --git a/projects/devdashboard/original_scripts/devdashboard.rb b/projects/devdashboard/original_scripts/devdashboard.rb new file mode 100755 index 0000000..ce5718c --- /dev/null +++ b/projects/devdashboard/original_scripts/devdashboard.rb @@ -0,0 +1,36 @@ +#!/usr/bin/ruby -w + +require 'developer' +require 'herds' +require 'userinfo' +require 'docparser' +require 'planetiniparser' +require 'metadataparser' +require 'projectparser' + +include Herds +include UserInfo +include PlanetIniParser +include MetadataHelper +include ProjectHelper + +#dev = Developer.new +# +#UserInfo.updateDev(dev) +#Herds.updateDev(dev) +#MetadataHelper.updateDev(dev) +#PlanetIniParser.updateDev(dev) +#dev.documentation = findDocumentation(dev.email) + + +developers = UserInfo.indexUsers() +#herds = Herds.indexHerds(developers) +#projects = ProjectHelper.indexProjects(developers) + +PlanetIniParser.updateDevs(developers) + +developers.each do |email, dev| + dev.print + puts +end + diff --git a/projects/devdashboard/original_scripts/developer.rb b/projects/devdashboard/original_scripts/developer.rb new file mode 100644 index 0000000..27954fb --- /dev/null +++ b/projects/devdashboard/original_scripts/developer.rb @@ -0,0 +1,109 @@ +#!/usr/bin/ruby -w + +require 'rss/2.0' +require 'open-uri' + +class Developer + attr_reader :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status, :projects, :projectMembership + attr_writer :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status, :projectMembership + + def initialize() + self.herds = Array.new + self.packages = Array.new + self.projectMembership = {} + end + + def ciaRss() + return "http://cia.navi.cx/stats/author/#{self.handle}/.rss" + end + + def forumsProfile() + myhandle = self.forumsHandle + myhandle = self.handle if myhandle.nil? + "http://forums.gentoo.org/profile.php?mode=viewprofile&u=#{myhandle}" + end + + def forumsPosts() + myhandle = self.forumsHandle + myhandle = self.handle if myhandle.nil? + "http://forums.gentoo.org/search.php?search_author=#{myhandle}" + end + + def myBugsRss() + "http://bugs.gentoo.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailreporter1=1&emailtype1=exact&email1=#{self.handle}%40gentoo.org&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&chfieldfrom=&chfieldto=Now&chfieldvalue=&query_based_on=My%20Open%20Bugs&field0-0-0=noop&type0-0-0=noop&value0-0-0=&ctype=rss" + end + + def parseRssForItems(feed) + items = [] + begin + open(feed) do |http| + rss_source = http.read + rss = RSS::Parser.parse(rss_source, true) + if rss.nil? + rss = RSS::Parser.parse(rss_source, true, false) + end + + unless rss.nil? + items = rss.items + end + end + # catch some errors that could occur... + rescue Exception + end + + return items + end + def commitItems() + parseRssForItems(self.ciaRss) + end + def blogItems() + parseRssForItems(self.blogRss) + end + + def print() + puts "Name: #{self.name}" unless self.name.nil? + puts "Username: #{self.handle}" + puts "Status: #{self.status}" + puts "Email: #{self.email}" + puts "PGP Key: #{self.pgpkey}" unless self.pgpkey.nil? + puts "Roles: #{self.roles}" unless self.roles.nil? + unless self.herds.nil? + puts "Herds: (#{self.herds.size})" + self.herds.each { |herd| puts "\t#{herd.name}"} + end + puts "Joined: #{self.joined}" unless self.joined.nil? + puts "Birthday: #{self.birthday}" unless self.birthday.nil? + puts "Location: #{self.location}" unless self.location.nil? +# unless self.blogRss.nil? +# puts "Blog RSS: #{self.blogRss}" +# puts "Blog Posts: " +# self.blogItems.each { |item| puts "\t#{item.title}" } +# puts "Hackergotchi: #{self.hackergotchi}" unless self.hackergotchi.nil? +# end + #puts "Commits RSS: #{self.ciaRss}" + #puts "Commits: " + #self.commitItems.each { |item| puts "\t#{item.title}" } + #puts "Bugs RSS: #{self.myBugsRss}" + puts "Forums Profile: #{self.forumsProfile}" + unless self.packages.empty? + puts "Packages:" + self.packages.each { |package| puts "\t#{package}" } + end + + unless self.projectMembership.nil? + puts "Projects: (#{self.projectMembership.size})" + self.projectMembership.each do |key, membership| + puts "\tProject: #{key}" + puts "\tRole: #{membership.role}" unless membership.role.nil? + puts "\tDescription: #{membership.description}" unless membership.description.nil? + puts + end + unless self.documentation.nil? + puts "Documentation:" + self.documentation.each do |doc| + puts "\t#{doc.title} : #{doc.role}" + end + end + end + end +end diff --git a/projects/devdashboard/original_scripts/doccacher.rb b/projects/devdashboard/original_scripts/doccacher.rb new file mode 100644 index 0000000..b555f9b --- /dev/null +++ b/projects/devdashboard/original_scripts/doccacher.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby -w + +require 'docparser.rb' + +findDocumentation("nichoj@gentoo.org") diff --git a/projects/devdashboard/original_scripts/docparser.rb b/projects/devdashboard/original_scripts/docparser.rb new file mode 100644 index 0000000..22ce566 --- /dev/null +++ b/projects/devdashboard/original_scripts/docparser.rb @@ -0,0 +1,62 @@ +#!/usr/bin/ruby -w +require 'rexml/document' +require 'find' +#require 'sqlite' +#require 'active_record' + +#ActiveRecord::Base.establish_connection(:adapter => "sqlite", :database => "./dbfile") + +include REXML + +def isXml? (filename) + filename =~ /\.xml$/ +end + +class Documentation + attr_reader :role, :title, :uri + attr_writer :role, :title, :uri + def initialize(role, title, uri) + self.role = role + self.title = title + self.uri = uri + end +end + +def findDocumentation(target) + documents = [] + targetdir="/local/home/checkouts/gentoo-website/xml/htdocs/proj/en/java/" + Dir.glob("#{targetdir}/**/*.xml").each do |filename| +# Find.find("/home/jnichols/checkouts/gentoo/xml/htdocs/proj/en/java") do |filename| + file = File.new(filename) + begin + doc = Document.new(file) + + root = doc.root + title_text = nil + case doc.doctype.system + when "/dtd/guide.dtd": + title = root.elements['title'] + title_text = title.text unless title.nil? + + when "/dtd/project.dtd": + longname = root.elements['longname'] + title_text = longname.text unless longname.nil? + else next + end + + + root.elements.each('author') do |author| + role = author.attributes['title'] + email = author.elements['mail'].attributes['link'] + if email == target + documentation = Documentation.new(role,title_text,filename) + documents.push documentation + end + end + rescue Exception + # catching all exceptions probably is bad :) + end + end + + return documents +end diff --git a/projects/devdashboard/original_scripts/herds.rb b/projects/devdashboard/original_scripts/herds.rb new file mode 100644 index 0000000..b1606a5 --- /dev/null +++ b/projects/devdashboard/original_scripts/herds.rb @@ -0,0 +1,56 @@ +#!/usr/bin/ruby -w + +module Herds + class Herd + attr_reader :name, :description, :email, :packages, :developers + attr_writer :name, :description, :email, :packages, :developers + def initialize(name) + self.name = name + self.packages = [] + self.developers = [] + end + end + + def Herds.indexHerds(developers) + herdsxml = '/home/nichoj/checkouts/gentoo-website/xml/htdocs/proj/en/metastructure/herds/herds.xml' + file = File.new(herdsxml) + doc = Document.new(file) + root = doc.root + + root.elements.each('herd') do |herdnode| + namenode = herdnode.elements['name'] + emailnode = herdnode.elements['email'] + descriptionnode = herdnode.elements['description'] + projectnode = herdnode.elements['maintainingproject'] + + herd = Herd.new(namenode.text) + herd.email = emailnode.text unless emailnode.nil? + herd.description = descriptionnode.text unless descriptionnode.nil? + + # look for maintainers if not part of a project + if projectnode.nil? + herdnode.elements.each('maintainer') do |maintainer| + email = maintainer.elements['email'].text + developer = developers[email] + unless developer.nil? + developer.herds.push(herd) + herd.developers.push(developer) + end + end +# else + end + end + end + + def Herds.getHerdsForDev(handle) + line = nil + IO.popen("herdstat -n -q -d #{handle}") do |pipe| + line = pipe.gets + end + line.split + end + + def Herds.updateDev(developer) + developer.herds = Herds.getHerdsForDev(developer.handle) + end +end diff --git a/projects/devdashboard/original_scripts/metadataparser.rb b/projects/devdashboard/original_scripts/metadataparser.rb new file mode 100644 index 0000000..2f7c5fa --- /dev/null +++ b/projects/devdashboard/original_scripts/metadataparser.rb @@ -0,0 +1,109 @@ +#!/usr/bin/ruby -w +require 'rexml/document' +require 'find' + +include REXML + + +module MetadataHelper + def MetadataHelper.isMetadata?(filename) + filename =~ /metadata\.xml$/ + end + + class Metadata + attr_reader :herds, :maintainers, :longdescription, :package + attr_writer :herds, :maintainers, :longdescription, :package + def initialize() + self.herds = Array.new + self.maintainers = Array.new + end + end + + class Maintainer + attr_reader :email, :name + attr_writer :email, :name + end + + + def MetadataHelper.parse_metadata (filename) + metadata = Metadata.new + + file = File.new(filename) + package = File.basename(File.dirname(filename)) + category = File.basename(File.dirname(File.dirname(filename))) + fullpackage = "#{category}/#{package}" + metadata.package = fullpackage + + doc = Document.new(file) + root = doc.root + + puts "Indexing #{filename}..." + root.elements.each('herd') do |herd| + metadata.herds.push herd.text + end + + root.elements.each('maintainer') do |maintainer_node| + maintainer = Maintainer.new + email = maintainer_node.elements['email'] + maintainer.email = email.text unless email.nil? + name = maintainer_node.elements['name'] + maintainer.name = name.text unless name.nil? + + metadata.maintainers.push maintainer + end + return metadata + end + + def MetadataHelper.parse_directory(directory) + indexed_metadata = [] + targetdir="/local/home/checkouts/gentoo-portage-tree/dev-java" + Dir.glob("#{targetdir}/**/*/metadata.xml").each do |filename| +# Find.find("/local/home/checkouts/gentoo-portage-tree/dev-java") do |filename| + if isMetadata? filename + metadata = parse_metadata(filename) + unless metadata.maintainers.empty? and metadata.herds.empty? + indexed_metadata.push(metadata) + end + end + end + + return indexed_metadata + end + + def MetadataHelper.updateDev(dev) + indexed_metadata = parse_directory("/local/home/checkouts/gentoo-portage-tree/dev-java") + + if dev.packages.nil? + dev.packages = [] + end + indexed_metadata.each do |metadata| + unless metadata.maintainers.empty? + metadata.maintainers.each do |maintainer| + if dev.email == maintainer.email + dev.packages.push metadata.package + end + end + + end + end + + end +end + + + +#indexed_metadata.each do |metadata| +# puts "* #{metadata.package}" +# unless metadata.herds.empty? +# puts "\tHerds:" +# puts "\t\t#{metadata.herds}" unless metadata.herds.empty? +# end +# unless metadata.maintainers.empty? +# puts "\tMaintainers:" +# metadata.maintainers.each do |maintainer| +# puts "\t\tname: #{maintainer.name}" +# puts "\t\temail: #{maintainer.email}" +# end +# puts +# end +#end diff --git a/projects/devdashboard/original_scripts/planetiniparser.rb b/projects/devdashboard/original_scripts/planetiniparser.rb new file mode 100755 index 0000000..ca22afc --- /dev/null +++ b/projects/devdashboard/original_scripts/planetiniparser.rb @@ -0,0 +1,64 @@ +#!/usr/bin/ruby -w + +require 'open-uri' +require 'pp' + +module PlanetIniParser + + def PlanetIniParser.updateDevs(developers) + planetUri = "http://sources.gentoo.org/viewcvs.py/*checkout*/planet/configs/planet.ini" + open(planetUri) do |file| + while line = file.gets do + if line =~ /^\[(.*)\]$/ + url = $1 + next if url == "Planet" or url == "DEFAULT" + +# data = {} +# while line = file.gets do +# line.chomp! +# break if line == "" +# line =~ /(.*) = (.*)/ +# data[$1] = $2 +# end +# +# developer = developers["#{data['username']}@gentoo.org"] +# unless developer.nil? +# unless data['face'].nil? +# developer.hackergotchi = "http://planet.gentoo.org/images/#{data['face']}" +# end +# +# developer.blogRss = url +# end + end + end + end + + end + +# def PlanetIniParser.updateDev(developer) +# planetUri = "http://sources.gentoo.org/viewcvs.py/*checkout*/planet/configs/planet.ini?rev=176" +# open(planetUri) do |file| +# while line = file.gets do +# if line =~ /^\[(.*)\]$/ +# url = $1 +# next if url == "Planet" or url == "DEFAULT" +# +# data = {} +# while line = file.gets do +# line.chomp! +# break if line == "" +# line =~ /(.*) = (.*)/ +# data[$1] = $2 +# end +# +# if data['username'] == developer.handle +# if ! data['face'].nil? +# developer.hackergotchi = "http://planet.gentoo.org/images/#{data['face']}" +# end +# developer.blogRss = url +# end +# end +# end +# end + +end diff --git a/projects/devdashboard/original_scripts/projectparser.rb b/projects/devdashboard/original_scripts/projectparser.rb new file mode 100644 index 0000000..290cb12 --- /dev/null +++ b/projects/devdashboard/original_scripts/projectparser.rb @@ -0,0 +1,92 @@ +#!/usr/bin/ruby -w + +require 'rexml/document' +include REXML + +module ProjectHelper + + class ProjectMember + attr_reader :role, :description, :developer, :project + attr_writer :role, :description, :developer, :project + def initialize() + end + end + + class Project + attr_reader :name, :longname, :lastUpdated, :description, :members + attr_writer :name, :longname, :lastUpdated, :description, :members + def initialize() + self.members = [] + end + + def get_member_by_handle(handle) + + end + end + + + def yank_single_text(elements, target) + result = nil + elements.each(target) do |node| + result = node.text + end + return result + end + + def yank_attribute(node, target) + node.attributes[target] + end + + def ProjectHelper.indexProjects(developers) + projects = [] + + target_dir = "/local/home/checkouts/gentoo-website/xml/htdocs/proj/*/**/index.xml" + Dir.glob(target_dir).each do |index| + puts "Reading #{index}..." + project = Project.new() + doc = Document.new(File.new(index)) + root = doc.root + + + project.name = yank_single_text(root.elements, 'name') + + if project.name.nil? + puts "No <name> defined in #{index}... trying to guess" + project.name = File.basename(File.dirname(index)) + end + + project.longname = yank_single_text(root.elements, 'longname') + project.description = yank_single_text(root.elements, 'description') + + root.elements.each('dev') do |devnode| + developer = developers["#{devnode.text}@gentoo.org"] + member = ProjectMember.new + member.role = yank_attribute(devnode, 'role') + member.description = yank_attribute(devnode, 'description') + member.developer = developer + member.project = project + developer.projectMembership[project.name] = member unless developer.nil? + + project.members.push(member) + end + + projects.push(project) + end + return projects + end + + def ProjectHelper.print(projects) + projects.each do |project| + puts "*#{project.name}:" + puts "\tLong Name: #{project.longname}" + puts "\tDescription: #{project.description}" + puts "\tMembers:" + project.members.each do |member| + puts "\t\tHandle: #{member.handle}" + puts "\t\tRole: #{member.role}" + puts "\t\tDescription: #{member.description}" + puts + end + end + end +end diff --git a/projects/devdashboard/original_scripts/userinfo.rb b/projects/devdashboard/original_scripts/userinfo.rb new file mode 100644 index 0000000..b875de8 --- /dev/null +++ b/projects/devdashboard/original_scripts/userinfo.rb @@ -0,0 +1,71 @@ +#!/usr/bin/ruby -w +require 'rexml/document' +include REXML + +module UserInfo + def UserInfo.indexUsers() + developers = {} + root = UserInfo.getRoot() + + root.elements.each('user') do |usernode| + developer = Developer.new + + developer.handle = usernode.attributes['username'] + developer.name = usernode.elements["realname"].attributes["fullname"] + developer.pgpkey = usernode.elements["pgpkey"].text + developer.email = usernode.elements["email"].text + developer.joined = usernode.elements["joined"].text +# developer.birthday = user.elements["birthday"].text + rolesnode = usernode.elements["roles"] + developer.roles = rolesnode.text unless rolesnode.nil? + + statusnode = usernode.elements['status'] + if statusnode.nil? + developer.status = 'active' + else + developer.status = statusnode.text + end + + locationnode = usernode.elements["location"] + developer.location = locationnode.text unless locationnode.nil? + + developers[developer.email] = developer + end + return developers + end + + def UserInfo.getRoot() + file = File.new('/home/nichoj/checkouts/gentoo/xml/htdocs/proj/en/devrel/roll-call/userinfo.xml') + doc = Document.new(file) + + return doc.root + end + + def UserInfo.parse(handle) + root = UserInfo.getRoot() + user = root.elements["user[@username='" + handle + "']"] + return user + end + + def UserInfo.dump(handle) + user = UserInfo.parse(handle) + puts "username = " + user.attributes["username"] + puts "realname = " + user.elements["realname"].attributes["fullname"] + puts "pgpkey = " + user.elements["pgpkey"].text + puts "email = " + user.elements["email"].text + puts "joined = " + user.elements["joined"].text +# puts "birthday = " + user.elements["birthday"].text + puts "roles = " + user.elements["roles"].text + puts "location = " + user.elements["location"].text + end + def UserInfo.updateDev(developer) + user = UserInfo.parse(developer.handle) + developer.name = user.elements["realname"].attributes["fullname"] + developer.pgpkey = user.elements["pgpkey"].text + developer.email = user.elements["email"].text + developer.joined = user.elements["joined"].text +# developer.birthday = user.elements["birthday"].text + developer.roles = user.elements["roles"].text + developer.location =user.elements["location"].text + end +end |