Remove some old cruft from sitecore.alt_tags
authorW. Trevor King <wking@drexel.edu>
Fri, 25 Jun 2010 20:04:29 +0000 (16:04 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 25 Jun 2010 20:04:29 +0000 (16:04 -0400)
sitecore/alt_tags.py
sitecore/prof_import.py

index 19fac3c71516c5cc2dd838429c9623998352373d..0948f43bc78c0b0b1390614e136da6dad06bc1c6 100644 (file)
@@ -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)
index 9b56280cc48badd8e5d56fd3351884a13f3ec979..b4d9a5463049afd107b7b743ea25b1a369989d29 100644 (file)
@@ -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()