Skip to content

Update snapshot functionality based on real world usage #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions vinca/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ def parse_command_line(argv):
default=None,
help="The conda platform to check existing recipes for.",
)
parser.add_argument(
"-z",
"--snapshot",
dest="snapshot",
default=None,
help="The version snapshot file (default: None)."
)
arguments = parser.parse_args(argv[1:])
global selected_platform
config.parsed_args = arguments
Expand Down Expand Up @@ -226,12 +219,12 @@ def read_vinca_yaml(filepath):
return vinca_conf


def read_snapshot(filepath):
if not filepath:
def read_snapshot(vinca_conf):
if not "rosdistro_snapshot" in vinca_conf:
return None

yaml = ruamel.yaml.YAML()
snapshot = yaml.load(open(filepath, "r"))
snapshot = yaml.load(open(vinca_conf["rosdistro_snapshot"], "r"))
return snapshot


Expand Down Expand Up @@ -868,8 +861,7 @@ def main():
base_dir = os.path.abspath(arguments.dir)
vinca_yaml = os.path.join(base_dir, "vinca.yaml")
vinca_conf = read_vinca_yaml(vinca_yaml)

snapshot = read_snapshot(arguments.snapshot)
snapshot = read_snapshot(vinca_conf)

from .template import generate_bld_ament_cmake
from .template import generate_bld_ament_python
Expand Down
7 changes: 6 additions & 1 deletion vinca/snapshot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import yaml
import datetime
from .distro import Distro


Expand Down Expand Up @@ -30,7 +31,7 @@ def main():
"--output",
type=str,
dest="output",
default="snapshot.yaml",
default="rosdistro_snapshot.yaml",
help="Output file to write dependencies to",
required=False,
)
Expand All @@ -44,6 +45,9 @@ def main():
)
args = parser.parse_args()

# Get the current UTC time
utc_time = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")

distro = Distro(args.distro)

if args.package is None:
Expand Down Expand Up @@ -72,4 +76,5 @@ def main():
print("{0:{2}} {1}".format(dep, version, max_len + 2))

with open(args.output, "w") as f:
f.write(f"# Snapshot generated by vinca-snapshot on {utc_time} UTC for distro {args.distro}\n")
yaml.dump(output, f)