Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/build_config/updateDailyVersion.py
169673 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
4
# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file updateDailyVersion.py
16
# @author Pablo Alvarez Lopez
17
# @date 2022-04-26
18
19
from __future__ import absolute_import
20
from __future__ import print_function
21
import os
22
import sys
23
import zipfile
24
import shutil
25
26
# first check platform (currently only available in Windows)
27
if sys.platform != "win32":
28
print("This script only works in Windows")
29
sys.exit()
30
31
# download sumo
32
print("Downloading daily SUMO...")
33
os.system('curl https://sumo.dlr.de/daily/sumo-win64extra-git.zip --output sumo.zip')
34
35
# now check if sumo.zip exist
36
if os.path.exists("sumo.zip"):
37
print("Download successful. Unzipping ...")
38
else:
39
print("Error downloading SUMO")
40
sys.exit()
41
42
# unzip SUMO
43
with zipfile.ZipFile("sumo.zip", 'r') as zip_ref:
44
zip_ref.extractall(".")
45
46
# check if sumo-git exists
47
if os.path.exists("sumo-git"):
48
print("Unzip successful. Updating SUMO folder ...")
49
else:
50
print("Error unzipping SUMO")
51
sys.exit()
52
53
# Copy all files
54
for src_dir, dirs, files in os.walk('./sumo-git'):
55
dst_dir = src_dir.replace('./sumo-git', '../../', 1)
56
if not os.path.exists(dst_dir):
57
os.makedirs(dst_dir)
58
for file_ in files:
59
src_file = os.path.join(src_dir, file_)
60
dst_file = os.path.join(dst_dir, file_)
61
if os.path.exists(dst_file):
62
# in case of the src and dst are the same file
63
if os.path.samefile(src_file, dst_file):
64
continue
65
os.remove(dst_file)
66
shutil.move(src_file, dst_dir)
67
68
# write info
69
print("All files copied. Cleaning ...")
70
71
# remove temporary files
72
os.remove("sumo.zip")
73
shutil.rmtree("sumo-git")
74
75
# finished
76
print("Done.")
77
78