• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python2
2#
3# Copyright 2017 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6"""Script to discard all the patches added to Android for this suite"""
7
8from __future__ import print_function
9
10import config
11import os
12import subprocess
13
14
15def discard_git(path):
16  try:
17    subprocess.check_call(['git', '-C', path, 'reset'])
18    subprocess.check_call(['git', '-C', path, 'clean', '-fdx'])
19    subprocess.check_call(['git', '-C', path, 'stash'])
20    print('Patch in %s removed successfully!' % path)
21  except subprocess.CalledProcessError:
22    print('Error while removing patch in %s' % path)
23
24
25def dispatch_skia():
26  skia_dir = os.path.join(config.android_home, config.bench_dict['Skia'])
27  discard_git(skia_dir)
28
29
30def dispatch_autotest():
31  autotest_dir = os.path.join(config.android_home, config.autotest_dir)
32  discard_git(autotest_dir)
33
34
35def dispatch_panorama():
36  panorama_dir = os.path.join(config.android_home,
37                              config.bench_dict['Panorama'])
38  discard_git(panorama_dir)
39
40
41def dispatch_synthmark():
42  synthmark_dir = 'synthmark'
43  try:
44    subprocess.check_call(
45        ['rm', '-rf',
46         os.path.join(config.android_home, synthmark_dir)])
47    print('Synthmark patch removed successfully!')
48  except subprocess.CalledProcessError:
49    print('Synthmark is not removed. Error occurred.')
50
51
52def main():
53  dispatch_skia()
54  dispatch_autotest()
55  dispatch_panorama()
56  dispatch_synthmark()
57
58
59if __name__ == '__main__':
60  main()
61