Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""LICENSE 

2Copyright 2017 Hermann Krumrey <hermann@krumreyh.com> 

3 

4This file is part of ci-scripts. 

5 

6ci-scripts is free software: you can redistribute it and/or modify 

7it under the terms of the GNU General Public License as published by 

8the Free Software Foundation, either version 3 of the License, or 

9(at your option) any later version. 

10 

11ci-scripts is distributed in the hope that it will be useful, 

12but WITHOUT ANY WARRANTY; without even the implied warranty of 

13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14GNU General Public License for more details. 

15 

16You should have received a copy of the GNU General Public License 

17along with ci-scripts. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20import os 

21from ci_scripts.common import process_call 

22 

23 

24def progstats_transfer(data: str, topic: str, project: str): 

25 """ 

26 Transfers progstats contents to the progstats instance using rsync 

27 :param data: The path to the data to transfer 

28 :param topic: The progstats topic name 

29 :param project: The progstats project name 

30 :return: None 

31 """ 

32 

33 progstats_data_path = os.environ["PROGSTATS_DATA_PATH"] 

34 progstats_data_port = os.environ["PROGSTATS_DATA_PORT"] 

35 progstats_host = progstats_data_path.split(":")[0] 

36 destination = os.path.join(progstats_data_path, topic, project) 

37 project_path = destination.split(":")[1] 

38 

39 if os.path.isdir(data) and not data.endswith("/"): 

40 data += "/" 

41 elif os.path.isfile(data): 

42 destination += "." + data.rsplit(".")[1] 

43 

44 mkdir_cmd = [ 

45 "ssh", 

46 "-p", progstats_data_port, 

47 progstats_host, 

48 "mkdir -p " + project_path 

49 ] 

50 rsync_cmd = [ 

51 "rsync", 

52 "-a", 

53 "--delete-after", 

54 "-e", "ssh -p " + progstats_data_port, 

55 data, 

56 destination 

57 ] 

58 process_call(mkdir_cmd) 

59 process_call(rsync_cmd)