--- /dev/null
+#!/usr/bin/python
+
+import sitecore
+
+if __name__ == '__main__':
+ import sys
+
+ command = sys.argv[1]
+ argv = sys.argv[1:]
+
+ mod_name = 'sitecore.' + command.replace('-', '.')
+ print mod_name
+ module = __import__(mod_name)
+ module.main(argv)
except ImportError, e:
WebDriver = e # allow some functionality without selenium
-def get_logger(verbose=0)
+def get_logger(verbose=0):
verbosities = [ # in order of decreasing severity
logging.CRITICAL,
logging.ERROR,
s.publish_section('Added alt tag for %s' % name)
-if __name__ == '__main__':
+def main(argv)
import optparse
usage = """%prog [options]
Xvfb :99 > /dev/null 2>&1 &
export DISPLAY=:99
java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 &
- ./sitecore/alt_tags.py
+ ./sc alt_tags
"""
p = optparse.OptionParser(usage)
p.add_option('-u', '--url', metavar='URL', dest='url',
Last Name* Last Name
Bio Brief Bio/Profile/Blurb
Short Bio Presentations (If applicable)
-Headshot* Photograph – Size should be width: 125px height: 150px
+Headshot* Photograph - Size should be width: 125px height: 150px
Email* Email
-Phone* Phone # ‐ Please use this format: (111) 111‐1111
+Phone* Phone # - Please use this format: (111) 111-1111
Fax Lab Name, Lab Phone (If applicable, please use "Lab Name, Lab Phone" format)
CV Resume
"""
class AttributeHolder (object):
- self.fields = []
+ fields = []
+
def __init__(self, *args, **kwargs):
for field in self.fields:
setattr(self, field, None)
class Name (AttributeHolder):
- self.fields = ['first_middle', 'last']
+ fields = ['first_middle', 'last']
class Graduation (AttributeHolder):
- self.fields = ['college', 'title', 'year']
+ fields = ['college', 'title', 'year']
class Contact (AttributeHolder):
- self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone']
+ fields = ['office', 'website', 'phone', 'lab', 'lab_phone']
class Bio (AttributeHolder):
- self.fields = ['specialization', 'publications', 'profile', 'cv']
+ fields = ['specialization', 'publications', 'profile', 'cv']
-class Professor (object):
- self.fields = ['name', 'graduations', 'contact', 'bio']
+class Professor (AttributeHolder):
+ fields = ['name', 'graduations', 'contact', 'bio']
self.table = table
def add_entry(self, dict, table=None):
- if table = None:
+ if table == None:
table = self.table
dict = self._clean_dict(dict)
keys = dict.keys()
# error checking
def list_entries(self, dict=None, table=None):
- if table = None:
+ if table == None:
table = self.table
where = self._where_string(dict)
self.cursor.execute('SELECT * FROM %s%s' % (table, where))
print '\t'.join(['%s' % x for x in row])
def delete_entries(self, dict, table=None):
- if table = None:
+ if table == None:
table = self.table
where = self._where_string(dict)
self.cursor.execute('DELETE FROM %s%s' % (table, where))
yield p
-if __name__ == '__main__':
+def main(argv):
import optparse
usage = """%prog [options] PROF_FILE
Where PROF_FILE is the output YAML file receiving professor data.
Example:
- ./sitecore/prof/export_mysql.py profs.yaml
+ ./sc prof-export_mysql profs.yaml
"""
p = optparse.OptionParser(usage)
p.add_option('-d', '--database', metavar='NAME', dest='database',
help='Name of the MySQL database (%default)',
default='directory')
- p.add_option(
p.add_option('-v', '--verbose', dest='verbose', action='count',
help='increment verbosity (%default)',
default=0)
- options,args = p.parse_args()
- ]
+ options,args = p.parse_args(argv)
prof_file = args[0]
db = SimpleDB(verbose=options.verbose)
s.open_nav_section(raw_name)
TODO
-if __name__ == '__main__':
+def main(argv):
import optparse
usage = """%prog [options] PROF_FILE
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
+ ./sc prof-import profs.yaml
"""
p = optparse.OptionParser(usage)
p.add_option('-u', '--url', metavar='URL', dest='url',
help='increment verbosity (%default)',
default=0)
- options,args = p.parse_args()
- ]
+ options,args = p.parse_args(argv)
prof_file = args[0]
profs = yaml.load(prof_file)