def get_config(user, item):
    """Return appropriate user info for a given item or None on failure"""
    try:
        user_info = parse_config('user_info/%s' % (user))
        return user_info[item]
    except IOError:
        pass
    except KeyError:
        pass
    return None
    def __init__(self, task, account):
        self.path = getenv('MW_HOME')
        assert self.path != None
        self.logger = logging.getLogger('mwtm_executor')

        self.task = task
        self.account = account
        self.timestr = datetime.utcnow().strftime('%Y%m%dT%H%M%S')
        self.config = parse_config('/'.join([path, 'etc',
                                            'vddb_async.conf']))

        self.result = None
        self.dna = None
        self.dna_duration = None
        self.dna_type = None
import sys 
from os import _exit, getenv
from sys import stderr

PROGRAM_INFO = "VDDB Async 1.0"

if len(sys.argv) > 1:
    print PROGRAM_INFO
    sys.exit(0)

path = getenv('MW_HOME')
if path == None:
    stderr.write("MW_HOME not set in environment, program cannot start.")
    _exit(1)
sys.path.append('/'.join([path, 'lib']))
os.environ['PATH'] = ':'.join([os.environ['PATH'], '/'.join([path, 'bin'])])
import logging, logging.config
from parse_config import parse_config
from utils import  make_db_pool, make_hbase_pool
import statsd
logging.config.fileConfig('/'.join([path, 'etc', 'logging.conf']))
logger = logging.getLogger('mw')
try:
    config = parse_config('/'.join([path, 'etc', 'vddb_async.conf']))
    hbpool = make_hbase_pool(config)
    pool = make_db_pool(config, 3)
except :
    logger.error('init task_adapter module failed !', exc_info=True)
    sys.exit(0)

def get_results():
  a = parse_config("./out.cfg")
  f = h5py.File('zsim-ev.h5', 'r')
  dset = f["stats"]["root"]

  def get(a, keys):
    for k in keys.split('.'):
      a = a[k]
    return a

  def total_cores(a):
    out = 0
    for core in get(a, 'sys.cores').values():
      out += int(core['cores'])
    return str(out)

  def cache_levels(a):
    for k, v in get(a, 'sys.caches').items():
      if v['parent'] == 'mem':
        assert(k.lower().startswith('l'))
        return k[1:]
    assert(False)

  def cache_shared_cores(a, cache_name):
    all_cores, = get(a, 'sys.cores').values()
    cache = get(a, 'sys.caches.' + cache_name)
    return str(int(all_cores['cores'])/int(cache['caches']))

  def core_type(a):
    all_cores, = get(a, 'sys.cores').values()
    if all_cores['type'] == 'OOO':
      return 'rob'
    else:
      return 'interval'

  def rob_timer_in_order(a):
    all_cores, = get(a, 'sys.cores').values()
    if all_cores['type'] == 'Simple':
      return '1'
    else:
      return '0'

  def cache_loads_stores(a, dset, zsim_cache_name, sniper_cache_name):
    # returns padded list
    def plist(l, n):
      return (list(l) + [0]*n)[:n]
    zcn = zsim_cache_name
    scn = sniper_cache_name
    is_l1 = zsim_cache_name in 'l1d l1i'.split()
    n_cores = len(core_instrs(a, dset))

    # We have to use plist() to have n_cores entries
    # in last level caches. Each entry is for each core.
    out = {scn + '.load-misses': plist(dset[zcn][-1]['mGETS'], n_cores),
           scn + '.loads': plist((dset[zcn][-1]['fhGETS'] if is_l1 else 0)+
                                  dset[zcn][-1]['hGETS'] +
                                  dset[zcn][-1]['mGETS'],
                                  n_cores),
           # TODO: check with bigger program
           scn + '.store-misses': plist(dset[zcn][-1]['mGETXIM'] +
                                        dset[zcn][-1]['mGETXSM'],
                                        n_cores),
           scn + '.stores': plist((dset[zcn][-1]['fhGETX'] if is_l1 else 0) +
                                   dset[zcn][-1]['hGETX'] +
                                   dset[zcn][-1]['mGETXIM'] +
                                   dset[zcn][-1]['mGETXSM'],
                                   n_cores)}
    return out

  def core_instrs(a, dset):
    core_name, = get(a, 'sys.cores').keys()
    return list(dset[core_name][-1]['instrs'])

  results = {
    'config': {'general/total_cores': total_cores(a),
              'perf_model/branch_predictor/mispredict_penalty': '17', # HARD
              'perf_model/cache/levels': cache_levels(a),

              'perf_model/core/frequency': str(float(get(a, 'sys.frequency'))/1000),
              'perf_model/core/interval_timer/dispatch_width': '4',  # HARD
              'perf_model/core/interval_timer/window_size': '128',   # HARD
              'perf_model/core/type': core_type(a),
              'perf_model/core/rob_timer/in_order': rob_timer_in_order(a),

              'perf_model/dram/controllers_interleaving': get(a, 'sys.mem.controllers'),
              'perf_model/dram/num_controllers': get(a, 'sys.mem.controllers'),

              'perf_model/l1_dcache/associativity': get(a, 'sys.caches.l1d.array.ways'),
              'perf_model/l1_dcache/cache_block_size': get(a, 'sys.lineSize'),
              'perf_model/l1_dcache/cache_size': str(int(get(a, 'sys.caches.l1d.size'))/1024),
              'perf_model/l1_dcache/data_access_time': get(a, 'sys.caches.l1d.latency'),

              'perf_model/l1_icache/associativity': get(a, 'sys.caches.l1i.array.ways'),
              'perf_model/l1_icache/cache_block_size': get(a, 'sys.lineSize'),
              'perf_model/l1_icache/cache_size': str(int(get(a, 'sys.caches.l1i.size'))/1024),
              'perf_model/l1_icache/data_access_time': get(a, 'sys.caches.l1i.latency'),

              'perf_model/l2_cache/associativity': get(a, 'sys.caches.l2.array.ways'),
              'perf_model/l2_cache/cache_block_size': get(a, 'sys.lineSize'),
              'perf_model/l2_cache/cache_size': str(int(get(a, 'sys.caches.l2.size'))/1024),
              'perf_model/l2_cache/data_access_time': get(a, 'sys.caches.l2.latency'),
              'perf_model/l2_cache/dvfs_domain': 'core',
              'perf_model/l2_cache/shared_cores': cache_shared_cores(a, 'l2'),

              'perf_model/l3_cache/associativity': get(a, 'sys.caches.l3.array.ways'),
              'perf_model/l3_cache/cache_size': str(int(get(a, 'sys.caches.l3.size'))/1024),
              'perf_model/l3_cache/dvfs_domain': 'global',
              'perf_model/l3_cache/shared_cores': cache_shared_cores(a, 'l3')},

   'results': {'dram.reads': [635, 0],
               'dram.writes': [0, 0],
               'fs_to_cycles_cores': [2.66e-06, 2.66e-06],
               'global.time': 177300000000,
               'global.time_begin': 0,
               'global.time_end': 177300000000,
               'interval_timer.uop_branch': [21372, 21555],
               'interval_timer.uop_fp_addsub': [19518, 19518],
               'interval_timer.uop_fp_muldiv': [15360, 15360],
               'interval_timer.uop_generic': [268651, 269088],
               'interval_timer.uop_load': [254884, 254896],
               'interval_timer.uop_store': [78007, 78248],
               'network.shmem-1.bus.num-packets': [0, 0],
               'network.shmem-1.bus.time-used': [0, 0],
               'performance_model.elapsed_time': [177306375244, 176602617436],
               'performance_model.instruction_count': core_instrs(a, dset)}}
  results['results'].update(cache_loads_stores(a, dset, 'l1d', 'L1-D'))
  results['results'].update(cache_loads_stores(a, dset, 'l1i', 'L1-I'))
  results['results'].update(cache_loads_stores(a, dset, 'l2', 'L2'))
  results['results'].update(cache_loads_stores(a, dset, 'l3', 'L3'))

  return results
def main():
    # use MW_HOME to find etc/ & var/ directories
    path = getenv('MW_HOME')
    if path == None:
        stderr.write("MW_HOME not set in environment, program cannot start.")
        _exit(1)
    logging.config.fileConfig('/'.join([path, 'etc', 'logging.conf']),
                              disable_existing_loggers=False)
    config = parse_config('/'.join([path, 'etc', 'vddb_async.conf']))
    start_dbpc(config, 'task_manager')

    # make db connection pool, assign 1 connection to each db accessing thread
    # kingship checker + db loader + task fetcher +
    # task cleanup : a total of 4 threads, + 1 manager thread pool
    db_pool = make_db_pool(config, DB_RESERVE_CONN + int(config['cleaner_threads_num']))
    # kingship granted event, all threads wait till this event is set
    hbase_pool = make_hbase_pool(config)

    kev = Event()
    kev.clear()
    # db load finished eventm all threads wait till this event is set
    lev = Event()
    lev.clear()
    # conditions each thread wait on, named after the waiter
    fetch_cond = Condition(Lock())
    pick_cond = Condition(Lock())
    manage_cond = Condition(Lock())
    clean_cond = Condition(Lock())
    # kingship checker
    check = Thread(target=check_kingship,
                   args=(config, db_pool, kev, config['tm_module_name'],
                         # NOTE: if task manager stops working for X minutes, the
                         #       tasks won't be scheduled and executed for X
                         #       minutes since tasks have to be finished in a
                         #       timely fashion, the task manager master timeout
                         #       should not be too long
                         int(config['tm_master_timeout']),
                         logging.getLogger('mwtm_tmcheck')))
    check.start()
    # all other threads wait here
    kev.wait()
    # this event is never cleared
    #assert kev.isSet()
    # worker threads, created in dependence order
    fetch = fetcher(config, db_pool, fetch_cond, pick_cond)
    clean = cleaner_cluster(config, db_pool, hbase_pool, clean_cond, manage_cond)
    manage = manager(config, db_pool, manage_cond, pick_cond, clean)
    pick = picker(config, pick_cond, fetch, manage)
    # db config observers, loader will notify them when there's new data loaded
    observers = [fetch, pick, manage, clean]
    load = Thread(target=load_database, args=(config, db_pool, lev, observers))
    # start the loader, and make other threads wait for the first load
    load.start()
    lev.wait()
    assert lev.isSet()

    # start all other threads
    fetch.start()
    clean.start()
    manage.start()
    pick.start()
    tasks = []
    while len(tasks) < total:
        print 'already fetched: ', len(tasks), 'tasks'
        print 'to fetch tasks from db'
        fetch.request(acc)
        for r in fetch.replies(True):
            ts = r[1]
            print 'fetched', len(ts), 'tasks'
            for t in ts:
                if t.uuid in rows:
                    tasks.append((t, rows[t.uuid]))

    return (clean, tasks)

logging.config.fileConfig('test_log.conf')
config = parse_config('test.conf')
pool = make_pool(config)

account = int(config['test_account'])
user = int(config['test_user'])
clean, tasks = setup(config, pool, account, user)

clean.start()

retry_codes = clean.backend_retry
retry = list(retry_codes)[0]
no_retry = max(retry_codes) + 1

i = 0

for use_row in (True, False):
Exemple #7
0
# setup flask
app = Flask(__name__)
app.config.from_object(__name__)
SECRET_KEY = os.urandom(20)
app.secret_key = SECRET_KEY
oauth = OAuth()
pd.set_option('display.max_colwidth', -1)

# Unicode Stringy Wahala!
# Ionno how this works but it fixes the ASCII error on Admin Page when reading from postgresql DB
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)

# Get Consumer Keys
my_config = parse_config()

# Use Twitter as example remote application
twitter = oauth.remote_app('twitter',
                           # unless absolute urls are used to make requests, this will be added
                           # before all URLs.  This is also true for request_token_url and others.
                           base_url='https://api.twitter.com/1/',
                           # where flask should look for new request tokens
                           request_token_url='https://api.twitter.com/oauth/request_token',
                           # where flask should exchange the token with the remote application
                           access_token_url='https://api.twitter.com/oauth/access_token',
                           # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
                           # they mostly work the same, but for sign on /authenticate is
                           # expected because this will give the user a slightly different
                           # user interface on the twitter side.
                           authorize_url='https://api.twitter.com/oauth/authenticate',
def main():
    if (len(sys.argv) == 2):
        if (sys.argv[1] == "app"):
            print("Copying resources ...")

            dst = os.environ["TARGET_BUILD_DIR"] + "/" + os.environ[
                "UNLOCALIZED_RESOURCES_FOLDER_PATH"]

            if os.path.exists(projectpath + "/resources/img/"):
                imgs = os.listdir(projectpath + "/resources/img/")
                for img in imgs:
                    print("copying " + img + " to " + dst)
                    shutil.copy(projectpath + "/resources/img/" + img, dst)

            if os.path.exists(projectpath + "/resources/fonts/"):
                fonts = os.listdir(projectpath + "/resources/fonts/")
                for font in fonts:
                    print("copying " + font + " to " + dst)
                    shutil.copy(projectpath + "/resources/fonts/" + font, dst)

    config = parse_config(projectpath)
    xcconfig = parse_xcconfig(
        os.path.join(os.getcwd(), IPLUG2_ROOT + '/common-ios.xcconfig'))

    CFBundleGetInfoString = config['BUNDLE_NAME'] + " v" + config[
        'FULL_VER_STR'] + " " + config['PLUG_COPYRIGHT_STR']
    CFBundleVersion = config['FULL_VER_STR']
    CFBundlePackageType = "BNDL"
    CSResourcesFileMapped = True
    LSMinimumSystemVersion = xcconfig['DEPLOYMENT_TARGET']

    print("Processing Info.plist files...")

    # AUDIOUNIT v3

    if config['PLUG_TYPE'] == 0:
        if config['PLUG_DOES_MIDI_IN']:
            COMPONENT_TYPE = kAudioUnitType_MusicEffect
        else:
            COMPONENT_TYPE = kAudioUnitType_Effect
    elif config['PLUG_TYPE'] == 1:
        COMPONENT_TYPE = kAudioUnitType_MusicDevice
    elif config['PLUG_TYPE'] == 2:
        COMPONENT_TYPE = kAudioUnitType_MIDIProcessor

    if config['PLUG_HAS_UI'] == 1:
        NSEXTENSIONPOINTIDENTIFIER = "com.apple.AudioUnit-UI"
    else:
        NSEXTENSIONPOINTIDENTIFIER = "com.apple.AudioUnit"

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-iOS-AUv3-Info.plist"

    NSEXTENSIONATTRDICT = dict(
        NSExtensionAttributes=dict(AudioComponents=[{}]),
        NSExtensionPointIdentifier=NSEXTENSIONPOINTIDENTIFIER)
    with open(plistpath, 'rb') as fp:
        auv3 = plistlib.load(fp)
    auv3['CFBundleExecutable'] = config['BUNDLE_NAME'] + "AppExtension"
    auv3['CFBundleIdentifier'] = "$(PRODUCT_BUNDLE_IDENTIFIER)"
    auv3['CFBundleName'] = config['BUNDLE_NAME'] + "AppExtension"
    auv3['CFBundleDisplayName'] = config['BUNDLE_NAME'] + "AppExtension"
    auv3['CFBundleVersion'] = CFBundleVersion
    auv3['CFBundleShortVersionString'] = CFBundleVersion
    auv3['CFBundlePackageType'] = "XPC!"
    auv3['NSExtension'] = NSEXTENSIONATTRDICT
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'] = [{}]
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'description'] = config['PLUG_NAME']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'manufacturer'] = config['PLUG_MFR_ID']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'name'] = config['PLUG_MFR'] + ": " + config['PLUG_NAME']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'subtype'] = config['PLUG_UNIQUE_ID']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'type'] = COMPONENT_TYPE
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'version'] = config['PLUG_VERSION_INT']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'sandboxSafe'] = True
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'tags'] = ["", ""]

    if config['PLUG_TYPE'] == 1:
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'tags'][0] = "Synth"
    else:
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'tags'][0] = "Effects"

    if config['PLUG_HAS_UI'] == 1:
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'tags'][1] = "size:{" + str(config['PLUG_WIDTH']) + "," + str(
                config['PLUG_HEIGHT']) + "}"
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'factoryFunction'] = "IPlugAUViewController_vIPlugInstrument"
        auv3['NSExtension']['NSExtensionMainStoryboard'] = config[
            'BUNDLE_NAME'] + "-iOS-MainInterface"
    else:
        auv3['NSExtension'][
            'NSExtensionPrincipalClass'] = "IPlugAUViewController_vIPlugInstrument"

    with open(plistpath, 'wb') as fp:
        plistlib.dump(auv3, fp)


# Standalone APP

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-iOS-Info.plist"
    with open(plistpath, 'rb') as fp:
        iOSapp = plistlib.load(fp)
    iOSapp['CFBundleExecutable'] = config['BUNDLE_NAME']
    iOSapp['CFBundleIdentifier'] = "$(PRODUCT_BUNDLE_IDENTIFIER)"
    iOSapp['CFBundleName'] = config['BUNDLE_NAME']
    iOSapp['CFBundleVersion'] = CFBundleVersion
    iOSapp['CFBundleShortVersionString'] = CFBundleVersion
    iOSapp['CFBundlePackageType'] = "APPL"
    iOSapp['LSApplicationCategoryType'] = "public.app-category.music"

    with open(plistpath, 'wb') as fp:
        plistlib.dump(iOSapp, fp)
Exemple #9
0
def main():

    config = parse_config(projectpath)

    today = datetime.date.today()

    CFBundleGetInfoString = config['BUNDLE_NAME'] + " v" + config[
        'FULL_VER_STR'] + " " + config['PLUG_COPYRIGHT_STR']
    CFBundleVersion = config['FULL_VER_STR']

    print "update_version.py - setting version to " + config['FULL_VER_STR']
    print "Updating plist version info..."

    plistpath = scriptpath + "/resources/IGraphicsTest-VST2-Info.plist"
    vst2 = plistlib.readPlist(plistpath)
    vst2['CFBundleGetInfoString'] = CFBundleGetInfoString
    vst2['CFBundleVersion'] = CFBundleVersion
    vst2['CFBundleShortVersionString'] = CFBundleVersion
    plistlib.writePlist(vst2, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    plistpath = scriptpath + "/resources/IGraphicsTest-AU-Info.plist"
    au = plistlib.readPlist(plistpath)
    au['CFBundleGetInfoString'] = CFBundleGetInfoString
    au['CFBundleVersion'] = CFBundleVersion
    au['CFBundleShortVersionString'] = CFBundleVersion
    plistlib.writePlist(au, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    plistpath = scriptpath + "/resources/IGraphicsTest-VST3-Info.plist"
    vst3 = plistlib.readPlist(plistpath)
    vst3['CFBundleGetInfoString'] = CFBundleGetInfoString
    vst3['CFBundleVersion'] = CFBundleVersion
    vst3['CFBundleShortVersionString'] = CFBundleVersion
    plistlib.writePlist(vst3, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    plistpath = scriptpath + "/resources/IGraphicsTest-macOS-Info.plist"
    app = plistlib.readPlist(plistpath)
    app['CFBundleGetInfoString'] = CFBundleGetInfoString
    app['CFBundleVersion'] = CFBundleVersion
    app['CFBundleShortVersionString'] = CFBundleVersion
    plistlib.writePlist(app, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    plistpath = scriptpath + "/resources/IGraphicsTest-AAX-Info.plist"
    aax = plistlib.readPlist(plistpath)
    aax['CFBundleGetInfoString'] = CFBundleGetInfoString
    aax['CFBundleVersion'] = CFBundleVersion
    aax['CFBundleShortVersionString'] = CFBundleVersion
    plistlib.writePlist(aax, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    print "Updating Mac Installer version info..."

    plistpath = scriptpath + "/installer/IGraphicsTest.pkgproj"
    installer = plistlib.readPlist(plistpath)

    for x in range(0, 5):
        installer['PACKAGES'][x]['PACKAGE_SETTINGS']['VERSION'] = config[
            'FULL_VER_STR']

    plistlib.writePlist(installer, plistpath)
    replacestrs(plistpath, "//Apple//", "//Apple Computer//")

    print "Updating Windows Installer version info..."

    for line in fileinput.input(scriptpath + "/installer/IGraphicsTest.iss",
                                inplace=1):
        if "AppVersion" in line:
            line = "AppVersion=" + config['FULL_VER_STR'] + "\n"
        sys.stdout.write(line)
def main():
    demo = 0

    if len(sys.argv) != 2:
        print("Usage: update_installer_version.py demo(0 or 1)")
        sys.exit(1)
    else:
        demo = int(sys.argv[1])

    config = parse_config(projectpath)

    # MAC INSTALLER

    print "Updating Mac Installer version info..."

    plistpath = projectpath + "/installer/" + config['BUNDLE_NAME'] + ".pkgproj"
    installer = plistlib.readPlist(plistpath)

    # range  = number of items in the installer (VST 2, VST 3, app, audiounit, aax)
    for x in range(0, 5):
        installer['PACKAGES'][x]['PACKAGE_SETTINGS']['VERSION'] = config[
            'FULL_VER_STR']

    if demo:
        installer['PROJECT']['PROJECT_PRESENTATION']['TITLE']['LOCALIZATIONS'][
            0]['VALUE'] = config['BUNDLE_NAME'] + " Demo"
        installer['PROJECT']['PROJECT_PRESENTATION']['INTRODUCTION'][
            'LOCALIZATIONS'][0]['VALUE']['PATH'] = "intro-demo.rtf"
    else:
        installer['PROJECT']['PROJECT_PRESENTATION']['TITLE']['LOCALIZATIONS'][
            0]['VALUE'] = config['BUNDLE_NAME']
        installer['PROJECT']['PROJECT_PRESENTATION']['INTRODUCTION'][
            'LOCALIZATIONS'][0]['VALUE']['PATH'] = "intro.rtf"

    plistlib.writePlist(installer, plistpath)
    #   replacestrs(plistpath, "//Apple//", "//Apple Computer//");

    # WIN INSTALLER
    print "Updating Windows Installer version info..."

    for line in fileinput.input(projectpath + "/installer/" +
                                config['BUNDLE_NAME'] + ".iss",
                                inplace=1):
        if "AppVersion" in line:
            line = "AppVersion=" + config['FULL_VER_STR'] + "\n"
        if "OutputBaseFilename" in line:
            if demo:
                line = "OutputBaseFilename=IPlugWebView Demo Installer\n"
            else:
                line = "OutputBaseFilename=IPlugWebView Installer\n"

        if 'Source: "readme' in line:
            if demo:
                line = 'Source: "readme-win-demo.rtf"; DestDir: "{app}"; DestName: "readme.rtf"; Flags: isreadme\n'
            else:
                line = 'Source: "readme-win.rtf"; DestDir: "{app}"; DestName: "readme.rtf"; Flags: isreadme\n'

        if "WelcomeLabel1" in line:
            if demo:
                line = "WelcomeLabel1=Welcome to the IPlugWebView Demo installer\n"
            else:
                line = "WelcomeLabel1=Welcome to the IPlugWebView installer\n"

        if "SetupWindowTitle" in line:
            if demo:
                line = "SetupWindowTitle=IPlugWebView Demo installer\n"
            else:
                line = "SetupWindowTitle=IPlugWebView installer\n"

        sys.stdout.write(line)
def main():
    config = parse_config(projectpath)
    xcconfig = parse_xcconfig(
        os.path.join(os.getcwd(), IPLUG2_ROOT + '/common-mac.xcconfig'))

    CFBundleGetInfoString = config['BUNDLE_NAME'] + " v" + config[
        'FULL_VER_STR'] + " " + config['PLUG_COPYRIGHT_STR']
    CFBundleVersion = config['FULL_VER_STR']
    CFBundlePackageType = "BNDL"
    CSResourcesFileMapped = True
    LSMinimumSystemVersion = xcconfig['DEPLOYMENT_TARGET']

    print "Copying resources ..."

    if config['PLUG_SHARED_RESOURCES']:
        dst = os.path.expanduser(
            "~") + "/Music/" + config['BUNDLE_NAME'] + "/Resources"
    else:
        dst = os.environ["TARGET_BUILD_DIR"] + os.environ[
            "UNLOCALIZED_RESOURCES_FOLDER_PATH"]

    if os.path.exists(dst) == False:
        os.makedirs(dst + "/", 0755)

    if os.path.exists(projectpath + "/resources/img/"):
        imgs = os.listdir(projectpath + "/resources/img/")
        for img in imgs:
            print "copying " + img + " to " + dst
            shutil.copy(projectpath + "/resources/img/" + img, dst)

    if os.path.exists(projectpath + "/resources/fonts/"):
        fonts = os.listdir(projectpath + "/resources/fonts/")
        for font in fonts:
            print "copying " + font + " to " + dst
            shutil.copy(projectpath + "/resources/fonts/" + font, dst)

    print "Processing Info.plist files..."

    # VST3

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-VST3-Info.plist"
    vst3 = plistlib.readPlist(plistpath)
    vst3['CFBundleExecutable'] = config['BUNDLE_NAME']
    vst3['CFBundleGetInfoString'] = CFBundleGetInfoString
    vst3['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".vst3." + config['BUNDLE_NAME'] + ""
    vst3['CFBundleName'] = config['BUNDLE_NAME']
    vst3['CFBundleVersion'] = CFBundleVersion
    vst3['CFBundleShortVersionString'] = CFBundleVersion
    vst3['LSMinimumSystemVersion'] = LSMinimumSystemVersion
    vst3['CFBundlePackageType'] = CFBundlePackageType
    vst3['CFBundleSignature'] = config['PLUG_UNIQUE_ID']
    vst3['CSResourcesFileMapped'] = CSResourcesFileMapped

    plistlib.writePlist(vst3, plistpath)

    # VST2

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-VST2-Info.plist"
    vst2 = plistlib.readPlist(plistpath)
    vst2['CFBundleExecutable'] = config['BUNDLE_NAME']
    vst2['CFBundleGetInfoString'] = CFBundleGetInfoString
    vst2['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".vst." + config['BUNDLE_NAME'] + ""
    vst2['CFBundleName'] = config['BUNDLE_NAME']
    vst2['CFBundleVersion'] = CFBundleVersion
    vst2['CFBundleShortVersionString'] = CFBundleVersion
    vst2['LSMinimumSystemVersion'] = LSMinimumSystemVersion
    vst2['CFBundlePackageType'] = CFBundlePackageType
    vst2['CFBundleSignature'] = config['PLUG_UNIQUE_ID']
    vst2['CSResourcesFileMapped'] = CSResourcesFileMapped

    plistlib.writePlist(vst2, plistpath)

    # AUDIOUNIT v2

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-au-Info.plist"
    auv2 = plistlib.readPlist(plistpath)
    auv2['CFBundleExecutable'] = config['BUNDLE_NAME']
    auv2['CFBundleGetInfoString'] = CFBundleGetInfoString
    auv2['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".audiounit." + config['BUNDLE_NAME'] + ""
    auv2['CFBundleName'] = config['BUNDLE_NAME']
    auv2['CFBundleVersion'] = CFBundleVersion
    auv2['CFBundleShortVersionString'] = CFBundleVersion
    auv2['LSMinimumSystemVersion'] = LSMinimumSystemVersion
    auv2['CFBundlePackageType'] = CFBundlePackageType
    auv2['CFBundleSignature'] = config['PLUG_UNIQUE_ID']
    auv2['CSResourcesFileMapped'] = CSResourcesFileMapped

    if config['PLUG_TYPE'] == 0:
        if config['PLUG_DOES_MIDI_IN']:
            COMPONENT_TYPE = kAudioUnitType_MusicEffect
        else:
            COMPONENT_TYPE = kAudioUnitType_Effect
    elif config['PLUG_TYPE'] == 1:
        COMPONENT_TYPE = kAudioUnitType_MusicDevice
    elif config['PLUG_TYPE'] == 2:
        COMPONENT_TYPE = kAudioUnitType_MIDIProcessor

    auv2['AudioUnit Version'] = config['PLUG_VERSION_HEX']
    auv2['AudioComponents'] = [{}]
    auv2['AudioComponents'][0]['description'] = config['PLUG_NAME']
    auv2['AudioComponents'][0]['factoryFunction'] = config['AUV2_FACTORY']
    auv2['AudioComponents'][0]['manufacturer'] = config['PLUG_MFR_ID']
    auv2['AudioComponents'][0][
        'name'] = config['PLUG_MFR'] + ": " + config['PLUG_NAME']
    auv2['AudioComponents'][0]['subtype'] = config['PLUG_UNIQUE_ID']
    auv2['AudioComponents'][0]['type'] = COMPONENT_TYPE
    auv2['AudioComponents'][0]['version'] = config['PLUG_VERSION_INT']
    auv2['AudioComponents'][0]['sandboxSafe'] = True

    plistlib.writePlist(auv2, plistpath)

    # AUDIOUNIT v3

    if config['PLUG_HAS_UI']:
        NSEXTENSIONPOINTIDENTIFIER = "com.apple.AudioUnit-UI"
    else:
        NSEXTENSIONPOINTIDENTIFIER = "com.apple.AudioUnit"

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-macOS-AUv3-Info.plist"
    auv3 = plistlib.readPlist(plistpath)
    auv3['CFBundleExecutable'] = config['BUNDLE_NAME']
    auv3['CFBundleGetInfoString'] = CFBundleGetInfoString
    auv3['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".app." + config['BUNDLE_NAME'] + ".AUv3"
    auv3['CFBundleName'] = config['BUNDLE_NAME']
    auv3['CFBundleVersion'] = CFBundleVersion
    auv3['CFBundleShortVersionString'] = CFBundleVersion
    auv3['LSMinimumSystemVersion'] = "10.12.0"
    auv3['CFBundlePackageType'] = "XPC!"
    auv3['NSExtension'] = dict(
        NSExtensionAttributes=dict(
            #                               AudioComponentBundle = "com.OliLarkin.app." + config['BUNDLE_NAME'] + ".AUv3.framework",
            AudioComponents=[{}]),
        #                               NSExtensionServiceRoleType = "NSExtensionServiceRoleTypeEditor",
        NSExtensionPointIdentifier=NSEXTENSIONPOINTIDENTIFIER,
        NSExtensionPrincipalClass="IPlugAUViewController")
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'] = [{}]
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'description'] = config['PLUG_NAME']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'manufacturer'] = config['PLUG_MFR_ID']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'name'] = config['PLUG_MFR'] + ": " + config['PLUG_NAME']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'subtype'] = config['PLUG_UNIQUE_ID']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'type'] = COMPONENT_TYPE
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'version'] = config['PLUG_VERSION_INT']
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'sandboxSafe'] = True
    auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
        'tags'] = [{}]

    if config['PLUG_TYPE'] == 1:
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'tags'][0] = "Synth"
    else:
        auv3['NSExtension']['NSExtensionAttributes']['AudioComponents'][0][
            'tags'][0] = "Effects"

    plistlib.writePlist(auv3, plistpath)

    # AAX

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-AAX-Info.plist"
    aax = plistlib.readPlist(plistpath)
    aax['CFBundleExecutable'] = config['BUNDLE_NAME']
    aax['CFBundleGetInfoString'] = CFBundleGetInfoString
    aax['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".aax." + config['BUNDLE_NAME'] + ""
    aax['CFBundleName'] = config['BUNDLE_NAME']
    aax['CFBundleVersion'] = CFBundleVersion
    aax['CFBundleShortVersionString'] = CFBundleVersion
    aax['LSMinimumSystemVersion'] = LSMinimumSystemVersion
    aax['CSResourcesFileMapped'] = CSResourcesFileMapped

    plistlib.writePlist(aax, plistpath)

    # APP

    plistpath = projectpath + "/resources/" + config[
        'BUNDLE_NAME'] + "-macOS-Info.plist"
    macOSapp = plistlib.readPlist(plistpath)
    macOSapp['CFBundleExecutable'] = config['BUNDLE_NAME']
    macOSapp['CFBundleGetInfoString'] = CFBundleGetInfoString
    macOSapp['CFBundleIdentifier'] = config['BUNDLE_DOMAIN'] + "." + config[
        'BUNDLE_MFR'] + ".app." + config['BUNDLE_NAME'] + ""
    macOSapp['CFBundleName'] = config['BUNDLE_NAME']
    macOSapp['CFBundleVersion'] = CFBundleVersion
    macOSapp['CFBundleShortVersionString'] = CFBundleVersion
    macOSapp['LSMinimumSystemVersion'] = LSMinimumSystemVersion
    macOSapp['CFBundlePackageType'] = CFBundlePackageType
    macOSapp['CFBundleSignature'] = config['PLUG_UNIQUE_ID']
    macOSapp['CSResourcesFileMapped'] = CSResourcesFileMapped
    macOSapp['NSPrincipalClass'] = "SWELLApplication"
    macOSapp['NSMainNibFile'] = config['BUNDLE_NAME'] + "-macOS-MainMenu"
    macOSapp['LSApplicationCategoryType'] = "public.app-category.music"
    macOSapp['CFBundleIconFile'] = config['BUNDLE_NAME'] + ".icns"
    macOSapp[
        'NSMicrophoneUsageDescription'] = "This app needs mic access to process audio."

    plistlib.writePlist(macOSapp, plistpath)
def main():
    if len(sys.argv) != 3:
        print("Usage: make_zip.py demo[0/1] zip[0/1]")
        sys.exit(1)
    else:
        demo = int(sys.argv[1])
        zip = int(sys.argv[2])

    config = parse_config(projectpath)

    dir = projectpath + "\\build-win\\out"

    if os.path.exists(dir):
        shutil.rmtree(dir)

    os.makedirs(dir)

    files = []

    if not zip:
        installer = "\\build-win\\installer\\PaloSandroSynth Installer.exe"

        if demo:
            installer = "\\build-win\\installer\\PaloSandroSynth Demo Installer.exe"

        files = [
            projectpath + installer, projectpath + "\installer\changelog.txt",
            projectpath + "\installer\known-issues.txt",
            projectpath + "\manual\PaloSandroSynth manual.pdf"
        ]
    else:
        files = [
            projectpath +
            "\\build-win\PaloSandroSynth.vst3\Contents\\x86_64-win\PaloSandroSynth.vst3",
            projectpath + "\\build-win\PaloSandroSynth_x64.exe"
        ]

    zipname = "PaloSandroSynth-v" + config['FULL_VER_STR']

    if demo:
        zipname = zipname + "-win-demo"
    else:
        zipname = zipname + "-win"

    zf = zipfile.ZipFile(projectpath + "\\build-win\\out\\" + zipname + ".zip",
                         mode="w")

    for f in files:
        print("adding " + f)
        zf.write(f, os.path.basename(f), zipfile.ZIP_DEFLATED)

    zf.close()
    print("wrote " + zipname)

    zf = zipfile.ZipFile(projectpath + "\\build-win\\out\\" + zipname +
                         "-pdbs.zip",
                         mode="w")

    files = [
        projectpath + "\\build-win\\pdbs\\PaloSandroSynth-vst3_x64.pdb",
        projectpath + "\\build-win\\pdbs\\PaloSandroSynth-app_x64.pdb"
    ]

    for f in files:
        print("adding " + f)
        zf.write(f, os.path.basename(f), zipfile.ZIP_DEFLATED)

    zf.close()
    print(zipname)