1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright 2020 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7"""Module to translate the xbuddy config.""" 8 9 10import os 11import sys 12 13 14if "/mnt/host/source/src/third_party/toolchain-utils/crosperf" in sys.path: 15 dev_path = os.path.expanduser("~/trunk/chromite/lib/xbuddy") 16 sys.path.append(dev_path) 17else: 18 print( 19 "This script can only be run from inside a ChromeOS chroot. Please " 20 "enter your chroot, go to ~/src/third_party/toolchain-utils/crosperf" 21 " and try again." 22 ) 23 sys.exit(0) 24 25# pylint: disable=import-error,wrong-import-position 26import xbuddy 27 28 29def Main(xbuddy_string): 30 if not os.path.exists("./xbuddy_config.ini"): 31 config_path = os.path.expanduser( 32 "~/trunk/chromite/lib/xbuddy/xbuddy_config.ini" 33 ) 34 os.symlink(config_path, "./xbuddy_config.ini") 35 x = xbuddy.XBuddy(manage_builds=False, static_dir="/tmp/devserver/static") 36 build_id = x.Translate(os.path.split(xbuddy_string)) 37 return build_id 38 39 40if __name__ == "__main__": 41 print(Main(sys.argv[1])) 42 sys.exit(0) 43