tools/mac/power/generate_scripts.py
def render(file_prefix, template_file, process_name, extra_args):
  """Render a single scenario script."""

  if file_prefix:
    file_prefix = file_prefix.replace(" ", "_") + "_"
    file_prefix = file_prefix.lower()

  # Roughly the Alexa top 50 at the time of writing this.
  background_sites_list = [
      "https://google.com", "https://youtube.com", "https://tmall.com",
      "https://baidu.com", "https://qq.com", "https://sohu.com",
      "https://amazon.com", "https://taobao.com", "https://facebook.com",
      "https://360.cn", "https://yahoo.com", "https://jd.com",
      "https://wikipedia.org", "https://zoom.us", "https://sina.com.cn",
      "https://weibo.com", "https://live.com", "https://xinhuanet.com",
      "https://reddit.com", "https://microsoft.com", "https://netflix.com",
      "https://office.com", "https://microsoftonline.com",
      "https://okezone.com", "https://vk.com", "https://myshopify.com",
      "https://panda.tv", "https://alipay.com", "https://csdn.net",
      "https://instagram.com", "https://zhanqi.tv", "https://yahoo.co.jp",
      "https://ebay.com", "https://apple.com", "https://bing.com",
      "https://bongacams.com", "https://google.com.hk", "https://naver.com",
      "https://stackoverflow.com", "https://aliexpress.com",
      "https://twitch.tv", "https://amazon.co.jp", "https://amazon.in",
      "https://adobe.com", "https://tianya.cn", "https://huanqiu.com",
      "https://aparat.com", "https://amazonaws.com", "https://twitter.com",
      "https://yy.com"
  ]
  background_sites = ",".join(background_sites_list)

  output_filename = f"./driver_scripts/{file_prefix}{template_file}.scpt"

  for render_target in get_render_targets(template_file, output_filename):

    render_target = {**render_target, **extra_args}

    env = Environment()
    env.loader = FileSystemLoader('.')
    template = env.get_template("driver_scripts_templates/" + template_file)

    with open(render_target["output_filename"], 'w') as output:
      output.write(
          template.render(**render_target,
                          directory=os.getcwd(),
                          background_sites=background_sites,
                          navigation_cycles=30,
                          per_navigation_delay=30,
                          delay=3600,
                          browser=process_name))
Render a single scenario script.
Render a single scenario script.
Render a single scenario script .
def render(file_prefix, template_file, process_name, extra_args):
  if file_prefix:
    file_prefix = file_prefix.replace(" ", "_") + "_"
    file_prefix = file_prefix.lower()
  background_sites_list = [
      "https://google.com", "https://youtube.com", "https://tmall.com",
      "https://baidu.com", "https://qq.com", "https://sohu.com",
      "https://amazon.com", "https://taobao.com", "https://facebook.com",
      "https://360.cn", "https://yahoo.com", "https://jd.com",
      "https://wikipedia.org", "https://zoom.us", "https://sina.com.cn",
      "https://weibo.com", "https://live.com", "https://xinhuanet.com",
      "https://reddit.com", "https://microsoft.com", "https://netflix.com",
      "https://office.com", "https://microsoftonline.com",
      "https://okezone.com", "https://vk.com", "https://myshopify.com",
      "https://panda.tv", "https://alipay.com", "https://csdn.net",
      "https://instagram.com", "https://zhanqi.tv", "https://yahoo.co.jp",
      "https://ebay.com", "https://apple.com", "https://bing.com",
      "https://bongacams.com", "https://google.com.hk", "https://naver.com",
      "https://stackoverflow.com", "https://aliexpress.com",
      "https://twitch.tv", "https://amazon.co.jp", "https://amazon.in",
      "https://adobe.com", "https://tianya.cn", "https://huanqiu.com",
      "https://aparat.com", "https://amazonaws.com", "https://twitter.com",
      "https://yy.com"
  ]
  background_sites = ",".join(background_sites_list)
  output_filename = f"./driver_scripts/{file_prefix}{template_file}.scpt"
  for render_target in get_render_targets(template_file, output_filename):
    render_target = {**render_target, **extra_args}
    env = Environment()
    env.loader = FileSystemLoader('.')
    template = env.get_template("driver_scripts_templates/" + template_file)
    with open(render_target["output_filename"], 'w') as output:
      output.write(
          template.render(**render_target,
                          directory=os.getcwd(),
                          background_sites=background_sites,
                          navigation_cycles=30,
                          per_navigation_delay=30,
                          delay=3600,
                          browser=process_name))
def render ( file_prefix , template_file , process_name , extra_args ) : if file_prefix : file_prefix = file_prefix . replace ( " " , "_" ) + "_" file_prefix = file_prefix . lower ( ) background_sites_list = [ "https://google.com" , "https://youtube.com" , "https://tmall.com" , "https://baidu.com" , "https://qq.com" , "https://sohu.com" , "https://amazon.com" , "https://taobao.com" , "https://facebook.com" , "https://360.cn" , "https://yahoo.com" , "https://jd.com" , "https://wikipedia.org" , "https://zoom.us" , "https://sina.com.cn" , "https://weibo.com" , "https://live.com" , "https://xinhuanet.com" , "https://reddit.com" , "https://microsoft.com" , "https://netflix.com" , "https://office.com" , "https://microsoftonline.com" , "https://okezone.com" , "https://vk.com" , "https://myshopify.com" , "https://panda.tv" , "https://alipay.com" , "https://csdn.net" , "https://instagram.com" , "https://zhanqi.tv" , "https://yahoo.co.jp" , "https://ebay.com" , "https://apple.com" , "https://bing.com" , "https://bongacams.com" , "https://google.com.hk" , "https://naver.com" , "https://stackoverflow.com" , "https://aliexpress.com" , "https://twitch.tv" , "https://amazon.co.jp" , "https://amazon.in" , "https://adobe.com" , "https://tianya.cn" , "https://huanqiu.com" , "https://aparat.com" , "https://amazonaws.com" , "https://twitter.com" , "https://yy.com" ] background_sites = "," . join ( background_sites_list ) output_filename = f"./driver_scripts/{file_prefix}{template_file}.scpt" for render_target in get_render_targets ( template_file , output_filename ) : render_target = { ** render_target , ** extra_args } env = Environment ( ) env . loader = FileSystemLoader ( '.' ) template = env . get_template ( "driver_scripts_templates/" + template_file ) with open ( render_target [ "output_filename" ] , 'w' ) as output : output . write ( template . render ( ** render_target , directory = os . getcwd ( ) , background_sites = background_sites , navigation_cycles = 30 , per_navigation_delay = 30 , delay = 3600 , browser = process_name ) )
Render a single scenario script.
Render a single scenario script .
"""Render a single scenario script.""" # Roughly the Alexa top 50 at the time of writing this.
file_prefix
template_file
process_name
extra_args