def process(indir, outdir, settingsfile, paramfile): """ Main sound file processing procedure. Finds all wave files in 'indir', reads them in one by one, and applies functions corresponding to each parameter in the parameters file. If no parameters file is specified, the default is "defaults/parameters/default.csv". If no settings file is specified, the default is "defaults/settings/default.csv" """ measurements = measure.measurements params = helpers.get_parameters(paramfile) settings = helpers.get_settings(settingsfile) frameshift = int(settings["frameshift"]) print ("indir=%s, outdir=%s" % (indir, outdir)) # make a list of wav files # TODO fix this so it uses absolute file paths (os.getenv) if indir[-1] != "/": indir = indir + "/" filelist = [indir + f for f in os.listdir(indir) if f.endswith(".wav")] for wav in filelist: print "Processing ", wav matfile = wav[:-3] + "mat" # TODO TextGrid stuff # build SoundFile object soundfile = helpers.SoundFile(settings, wav) # run the measurements for param in params: soundfile.measurements[param] = measurements[param](soundfile) # it is what it is... print "Done processing."
def user_json(request): if request.user.is_authenticated(): user_json = {'id': request.user.id, 'username': request.user.username} else: user_json = {} return render_to_json_response({ 'user': user_json, 'settings': get_settings() })
def user_json(request): if request.user.is_authenticated(): user_json = { 'id': request.user.id, 'username': request.user.username } else: user_json = {} return render_to_json_response({'user': user_json, 'settings': get_settings()})
def generate_test_file(wavfile): ''' Generates a file from a wave file in defaults/sounds to use for testing purposes ''' global tester sf = "../defaults/settings/default.csv" pf = "../defaults/parameters/default.csv" settings = helpers.get_settings(sf) params = helpers.get_parameters(pf) Fs, data = sio.read(wavfile) data_len = math.floor(len(data) / Fs * 1000 / int(settings['frameshift'])) soundfile = helpers.SoundFile(settings, wavfile) return soundfile
from helpers import read_data, get_settings, package_translation import api settings = get_settings() article_map = read_data('article_map') locales = ['de', 'es', 'fr', 'ja', 'pt-br'] for article in article_map: url = '{}/articles/{}/translations/missing.json'.format( settings['src_root'], article) missing_locales = api.get_resource_list(url, list_name='locales', paginate=False) for locale in locales: if locale in missing_locales: # if translation missing in src, nothing to move continue print('Moving {} translation for article {}'.format(locale, article)) # get translation in src hc url = '{}/articles/{}/translations/{}.json'.format( settings['src_root'], article, locale) translation = api.get_resource(url) # create translation in dest hc url = '{}/articles/{}/translations.json'.format( settings['dst_root'], article_map[article]) payload = package_translation(translation) api.post_resource(url, payload) print('\nFinished moving translations.\n')
import baconMessages as msg import helpers, os, re settings = helpers.get_settings() def execute(): baconBitsPath = helpers.run_command_output('cd {} && cd ../ && pwd'.format(helpers.path('util')), False).replace('\n', '') baconrcFile = baconBitsPath + '/.baconrc' DATA = helpers.read_file(baconrcFile) utilList = os.listdir(baconBitsPath) addPerks = helpers.kv_set(settings, 'perks') count = 0 # print(utilList) # print(addPerks) APPENDED_DATA_STR = DATA for item in utilList: path = baconBitsPath + '/' + item try: alias = helpers.get_alias(path) except: alias = False if alias: aliasStr = 'alias {ALIAS}="python {PATH}/actions.py"'.format(ALIAS= alias, PATH= path) # print(aliasStr) pat = re.compile(aliasStr) match = re.search(pat, DATA) if not match: count += 1 print('\nadding alias: {}'.format(alias)) APPENDED_DATA_STR += '\n' + aliasStr if addPerks == "True" or addPerks == "true":
new_message = Message(text=text, author=author, date=date) if new_message.is_valid(): HackGMSDatabase.create_message_record(new_message) response = make_response(json.dumps(new_message.ready_for_json()), 200) else: error_list = '; '.join(new_message.errors) response = make_response("There were errors creating your message: %s" % error_list, 400) return response # Deletes the message with the specified id if it exists. # If it does not exist, do nothing and report that the delete # was unsuccessful. @app.route('/api/messages/delete/<int:message_id>') def deleteMessage(message_id): message_to_delete = Message.get_message_by_id(message_id) if message_to_delete is not None: HackGMSDatabase.delete_message_record(message_to_delete) response = make_response("Message %s was deleted." % message_id, 200) else: response = make_response("Message %s does not exist." % message_id, 404) return response # Now that we've created the app, let's run it! settings = get_settings() set_up_log() app.debug = settings['debug_mode'] app.logger.info(" * Press Control+C to stop the server. Log messages are being "+ "saved to %s" % settings['log_file']) app.run(host=settings['host'], port=settings['port'])
from pathlib import Path from helpers import get_settings, get_ditamap_articles, package_translation import api hc = get_settings('hc') ditamap_articles = get_ditamap_articles() transformed_files = Path('transformed_dita_files') files = list(transformed_files.glob(f'**/*.html')) skips = [] for file in files: isMapped = False for article in ditamap_articles: if article['dita'] == file.stem: isMapped = True if article['id'] is None: skips.append( ' - \"{}\" (article id not defined in the ditamap)'. format(file.name)) continue # if article['dita'] not in ['out_email_template']: # test articles # continue print('Publishing \"{}\" as {}'.format(file.name, article['id'])) url = '{}/articles/{}/translations/{}.json'.format( hc['root'], article['id'], hc['locale']) payload = package_translation(file) response = api.put_resource(url, payload) if response is False: skips.append(' - \"{}\" (failed to update article)'.format( file.name)) break