Because relative imports don't work with
$ ./sitecore/prof/export_mysql.py
etc.
Also a number of syntax fixups and unicode -> ascii translations.
--- /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
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,
verbosities = [ # in order of decreasing severity
logging.CRITICAL,
logging.ERROR,
s.publish_section('Added alt tag for %s' % name)
s.publish_section('Added alt tag for %s' % name)
-if __name__ == '__main__':
import optparse
usage = """%prog [options]
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 &
Xvfb :99 > /dev/null 2>&1 &
export DISPLAY=:99
java -jar selenium-server-1.0.2-SNAPSHOT-standalone.jar > /dev/null 2>&1 &
"""
p = optparse.OptionParser(usage)
p.add_option('-u', '--url', metavar='URL', dest='url',
"""
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)
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
-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
Fax Lab Name, Lab Phone (If applicable, please use "Lab Name, Lab Phone" format)
CV Resume
"""
class AttributeHolder (object):
"""
class AttributeHolder (object):
def __init__(self, *args, **kwargs):
for field in self.fields:
setattr(self, field, None)
def __init__(self, *args, **kwargs):
for field in self.fields:
setattr(self, field, None)
class Name (AttributeHolder):
class Name (AttributeHolder):
- self.fields = ['first_middle', 'last']
+ fields = ['first_middle', 'last']
class Graduation (AttributeHolder):
class Graduation (AttributeHolder):
- self.fields = ['college', 'title', 'year']
+ fields = ['college', 'title', 'year']
class Contact (AttributeHolder):
class Contact (AttributeHolder):
- self.fields = ['office', 'website', 'phone', 'lab', 'lab_phone']
+ fields = ['office', 'website', 'phone', 'lab', 'lab_phone']
class Bio (AttributeHolder):
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):
self.table = table
def add_entry(self, dict, table=None):
table = self.table
dict = self._clean_dict(dict)
keys = dict.keys()
table = self.table
dict = self._clean_dict(dict)
keys = dict.keys()
# error checking
def list_entries(self, dict=None, table=None):
# error checking
def list_entries(self, dict=None, table=None):
table = self.table
where = self._where_string(dict)
self.cursor.execute('SELECT * FROM %s%s' % (table, where))
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):
print '\t'.join(['%s' % x for x in row])
def delete_entries(self, dict, table=None):
table = self.table
where = self._where_string(dict)
self.cursor.execute('DELETE FROM %s%s' % (table, where))
table = self.table
where = self._where_string(dict)
self.cursor.execute('DELETE FROM %s%s' % (table, where))
-if __name__ == '__main__':
import optparse
usage = """%prog [options] PROF_FILE
Where PROF_FILE is the output YAML file receiving professor data.
Example:
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 = optparse.OptionParser(usage)
p.add_option('-d', '--database', metavar='NAME', dest='database',
help='Name of the MySQL database (%default)',
default='directory')
p.add_option('-v', '--verbose', dest='verbose', action='count',
help='increment verbosity (%default)',
default=0)
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)
prof_file = args[0]
db = SimpleDB(verbose=options.verbose)
s.open_nav_section(raw_name)
TODO
s.open_nav_section(raw_name)
TODO
-if __name__ == '__main__':
import optparse
usage = """%prog [options] PROF_FILE
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 &
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',
"""
p = optparse.OptionParser(usage)
p.add_option('-u', '--url', metavar='URL', dest='url',
help='increment verbosity (%default)',
default=0)
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)
prof_file = args[0]
profs = yaml.load(prof_file)