• 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_autotest():
26    autotest_dir = os.path.join(config.android_home, config.autotest_dir)
27    discard_git(autotest_dir)
28
29
30def dispatch_panorama():
31    panorama_dir = os.path.join(config.android_home,
32                                config.bench_dict['Panorama'])
33    discard_git(panorama_dir)
34    try:
35        subprocess.check_call(['rm', '-rf', panorama_dir])
36        print('Panorama benchmark directory deleted successfully!')
37    except subprocess.CalledProcessError:
38        print('Error deleting Panorama benchmark directory')
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_autotest()
54    dispatch_panorama()
55    dispatch_synthmark()
56
57
58if __name__ == '__main__':
59    main()
60