Don't worry about sections that we can't lock
authorW. Trevor King <wking@drexel.edu>
Thu, 24 Jun 2010 20:34:17 +0000 (16:34 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 24 Jun 2010 20:34:17 +0000 (16:34 -0400)
sitecore.py

index 994f26bc4883fd85be59d53dfc4a604e5dff56b2..6d864fde8d04ffd19bcfc2bf00e5ca1c861a77a3 100755 (executable)
@@ -33,6 +33,7 @@ import logging
 import time
 
 from selenium.firefox.webdriver import WebDriver
+from selenium.common.exceptions import NoSuchElementException
 
 
 class SiteCoreConnection (object):
@@ -176,7 +177,11 @@ def add_headshot_alt_tags(s):
         name = ' '.join([x.capitalize() for x in raw_name.split('_')])
         s.logger.info('setting alt tag "%s" for %s' % (name, raw_name))
         s.open_nav_section(raw_name)
-        s.lock_section()
+        try:
+            s.lock_section()
+        except NoSuchElementException, e:
+            s.logger.info("can't lock %s (already locked?), skipping" % raw_name)
+            continue
         alt_granddad,alt_tag = s.find_field('Alt:')
         alt_tag.clear()
         alt_tag.send_keys(name)