2 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
4 # This file is part of SiteCorePy.
6 # SiteCorePy is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 2 of the License, or (at your
9 # option) any later version.
11 # SiteCorePy is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with SiteCorePy. If not, see <http://www.gnu.org/licenses/>.
19 """Move Professors from YAML -> Sitecore.
21 Professors will be created in:
22 Content -> Drexel -> ? -> physics -> ?
25 from selenium.common.exceptions import NoSuchElementException
28 from .. import SiteCoreConnection
29 from . import Name, Graduation, Contact, Bio, Professor
32 class ProfessorAdder (object):
33 """See doc/faculty.txt for Drexel's field/format policy.
35 def __init__(self, sitecore_connection):
36 self.s = sitecore_connection
39 #self.s.expand_nav_section('sitecore')
40 #self.s.expand_nav_section('Content')
41 self.s.expand_nav_section('Home')
42 self.s.expand_nav_section('physics')
43 self.s.expand_nav_section('contact')
44 self.s.expand_nav_section('facultyDirectory')
46 def __call__(self, prof):
47 self.create_prof_page(prof)
48 self.s.open_nav_section(raw_name)
51 def create_prof_page(self, prof):
52 self.s.open_nav_section('Copy of Shyamalendu Bose')
53 self.s.w.find_element_by_link_text('Copy To').click()
54 time.sleep(self.s.wait_time)
55 windows = self.w.get_window_handles()
56 current_window = self.w.get_current_window_handle()
57 self.logger.info('handling copy popup %s (from %s)'
58 % (current_window, windows))
59 name = self.s.find_element_by_id('Filename')
62 '/sitecore/content/Home/physics/contact/facultyDirectory/%s %s'
63 % (prof.name.first, prof.name.last))
64 self.s.w.find_element_by_link_text('Copy').click()
65 time.sleep(self.s.wait_time)
70 usage = """%prog [options] PROF_FILE
72 Where PROF_FILE is a YAML file containing professor data.
74 Example setup before running:
75 Xvfb :99 > /dev/null 2>&1 &
77 java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 &
78 ./sc.py prof-import profs.yaml
80 p = optparse.OptionParser(usage)
81 p.add_option('-u', '--url', metavar='URL', dest='url',
82 help='set the website URL (%default)',
83 default='https://webedit.drexel.edu/sitecore/login')
84 p.add_option('-v', '--verbose', dest='verbose', action='count',
85 help='increment verbosity (%default)',
88 options,args = p.parse_args(argv[1:])
90 profs = yaml.load(prof_file)
92 s = SiteCoreConnection(options.url, options.verbose)