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)
from selenium.common.exceptions import NoSuchElementException
from . import SiteCoreConnection
+import yaml
class AttributeHolder (object):
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']
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()