blob: 00c457efa3a81673697e8aa25f4666edcf46d728 [file] [log] [blame]
Zhizhou Yange5986902017-08-10 17:37:53 -07001#!/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):
Zhizhou Yang62362922017-08-30 16:04:36 -070016 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)
Zhizhou Yange5986902017-08-10 17:37:53 -070023
24
Zhizhou Yange5986902017-08-10 17:37:53 -070025def dispatch_autotest():
Zhizhou Yang62362922017-08-30 16:04:36 -070026 autotest_dir = os.path.join(config.android_home, config.autotest_dir)
27 discard_git(autotest_dir)
Zhizhou Yange5986902017-08-10 17:37:53 -070028
29
30def dispatch_panorama():
Zhizhou Yang62362922017-08-30 16:04:36 -070031 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')
Zhizhou Yange5986902017-08-10 17:37:53 -070039
40
41def dispatch_synthmark():
Zhizhou Yang62362922017-08-30 16:04:36 -070042 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.')
Zhizhou Yange5986902017-08-10 17:37:53 -070050
51
52def main():
Zhizhou Yang62362922017-08-30 16:04:36 -070053 dispatch_autotest()
54 dispatch_panorama()
55 dispatch_synthmark()
Zhizhou Yange5986902017-08-10 17:37:53 -070056
57
58if __name__ == '__main__':
Zhizhou Yang62362922017-08-30 16:04:36 -070059 main()