+ pass
+
+@task
+def file_setup():
+ """
+ Deploy expected files and directories from non-apt system services.
+ """
+ ini_parser = ConfigParser.SafeConfigParser()
+ # read remote data into a file like object
+ data_flo = StringIO(run('cat {supervisor_conf}'.format(**env)))
+ ini_parser.readfp(data_flo)
+ for section, option in (('supervisord','logfile'),
+ ('supervisord','pidfile'),
+ ('unix_http_server','file'),
+ ('program:celeryd','stdout_logfile')):
+ if not ini_parser.has_section(section):
+ raise Exception("Could not parse INI file {supervisor_conf}".format(**env))
+ filepath = ini_parser.get(section, option)
+ # generate file's directory structure if needed
+ run('mkdir -p {0}'.format(os.path.split(filepath)[0]))
+ # touch a file and change ownership if needed
+ if 'log' in option and not files.exists(filepath):
+ sudo('touch {0}'.format(filepath))
+ sudo('chown {0}:{1} {2}'.format(env.django_user, env.group, filepath))
+
+@task
+def check_secrets():
+ """
+ Ensure secret files exist for syncdb to run.
+ """
+
+ secrets_path = env.code_root + '/karmaworld/secret'
+ secrets_files = ('filepicker.py', 'static_s3.py', 'drive.py', 'client_secrets.json', 'drive.p12')
+
+ errors = []
+ for sfile in secrets_files:
+ ffile = os.path.sep.join((secrets_path,sfile))
+ if not files.exists(ffile):
+ errors.append('{0} missing. Please add and try again.'.format(ffile))
+ if errors:
+ raise Exception('\n'.join(errors))
+
+@task
+def fetch_usde():
+ """
+ Download USDE accreditation school CSV.
+ """
+ virtenv_exec('{0}/manage.py fetch_usde_csv {1}'.format(env.code_root, env.usde_csv))
+
+@task
+def import_usde():
+ """
+ Import accreditation school CSV into the database and scrub it.
+ """
+ virtenv_exec('{0}/manage.py import_usde_csv {1}'.format(env.code_root, env.usde_csv))
+ virtenv_exec('{0}/manage.py sanitize_usde_schools'.format(env.code_root))
+