From: W. Trevor King Date: Fri, 25 Jun 2010 20:04:29 +0000 (-0400) Subject: Remove some old cruft from sitecore.alt_tags X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c8c30a6cc0073491403a909bedd7978bf56224ba;p=sitecorepy.git Remove some old cruft from sitecore.alt_tags --- diff --git a/sitecore/alt_tags.py b/sitecore/alt_tags.py index 19fac3c..0948f43 100644 --- a/sitecore/alt_tags.py +++ b/sitecore/alt_tags.py @@ -59,15 +59,12 @@ Example setup before running: Xvfb :99 > /dev/null 2>&1 & export DISPLAY=:99 java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 & - ./sitecore.py + ./sitecore/alt_tags.py """ p = optparse.OptionParser(usage) p.add_option('-u', '--url', metavar='URL', dest='url', help='set the website URL (%default)', default='https://webedit.drexel.edu/sitecore/login') - p.add_option('-r', '--reload', metavar='NUM', dest='reload', type='int', - help='if a page load fails, try again NUM times (%default)', - default=5) p.add_option('-v', '--verbose', dest='verbose', action='count', help='increment verbosity (%default)', default=0) diff --git a/sitecore/prof_import.py b/sitecore/prof_import.py index 9b56280..b4d9a54 100644 --- a/sitecore/prof_import.py +++ b/sitecore/prof_import.py @@ -25,6 +25,7 @@ Professors will be created in: from selenium.common.exceptions import NoSuchElementException from . import SiteCoreConnection +import yaml class AttributeHolder (object): @@ -46,7 +47,7 @@ class Graduation (AttributeHolder): self.fields = ['college', 'title', 'year'] class Contact (AttributeHolder): - self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone' + self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone'] class Bio (AttributeHolder): self.fields = ['specialization', 'publications', 'profile', 'cv'] @@ -54,3 +55,56 @@ class Bio (AttributeHolder): class Professor (object): self.fields = ['name', 'graduations', 'contact', 'bio'] + +class ProfessorAdder (object): + """See doc/faculty.txt for Drexel's field/format policy. + """ + def __init__(self, sitecore_connection): + self.s = sitecore_connection + + def setup(self): + s.expand_nav_section('Media Library') + s.expand_nav_section('Images') + s.expand_nav_section('physics') + s.expand_nav_section('headshots') + + def __call__(self, prof): + raw_name = + s.open_nav_section(raw_name) + + +if __name__ == '__main__': + import optparse + usage = """%prog [options] PROF_FILE + +Where PROF_FILE is a YAML file containing professor data. + +Example setup before running: + Xvfb :99 > /dev/null 2>&1 & + export DISPLAY=:99 + java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 & + ./sitecore/prof_import.py profs.yaml +""" + p = optparse.OptionParser(usage) + p.add_option('-u', '--url', metavar='URL', dest='url', + help='set the website URL (%default)', + default='https://webedit.drexel.edu/sitecore/login') + p.add_option('-v', '--verbose', dest='verbose', action='count', + help='increment verbosity (%default)', + default=0) + + options,args = p.parse_args() + ] + prof_file = args[0] + profs = yaml.load(prof_file) + + s = SiteCoreConnection(options.url, options.verbose) + s.start() + try: + s.login() + a = ProfessorAdder(s) + a.setup() + for prof in profs: + a.aadd_profs(s, profs) + finally: + s.stop()