forked from ros-infrastructure/superflore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature Parity for Open Embedded (ros-infrastructure#79)
* Switch to use util functions. * Use the generate_installers function from superflore.generate_installers * Linting * Change the ros_meta class to be RosMeta, as well as changed the inheritance to be a member of the class (see ros-infrastructure#52). * Removed the sym-linked structure to behave more like the Gentoo generator (see ros-infrastructure#51). * Removed a commented line from the ebuild logic copypasta, changed the print format slightly for the exception output after a failed pr, and called the file_pr function. * Add temporary file manager code, as suggested by @tfoote. * Switch to utils print functions for TempfileManager output. * Use tempfile manager to clean up temp directories at exit. * Linting. * Remove hard-coded org and repo from RepoInstance call. * Reorder import statements. * Ok, that's pretty cool. * Apply new TempfileManager usage to OpenEmbedded logic. * OpenEmbedded generation is now running. ToDo: automatically clean up the tar files. * Files were not generating in the directory, but are now. * Fixed argument mapping for ebuild generator.
- Loading branch information
Showing
7 changed files
with
378 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2017 Open Source Robotics Foundation | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import errno | ||
import os | ||
import shutil | ||
import subprocess | ||
import tempfile | ||
|
||
from superflore.utils import err | ||
from superflore.utils import info | ||
|
||
|
||
class TempfileManager: | ||
def __init__(self, path): | ||
self.arg_path = path | ||
self.temp_path = None | ||
|
||
def __enter__(self): | ||
if self.arg_path: | ||
try: | ||
os.mkdir(self.arg_path) | ||
except OSError as ex: | ||
if ex.errno != errno.EEXIST: | ||
raise | ||
return self.arg_path | ||
else: | ||
self.temp_path = tempfile.mkdtemp() | ||
info("Working in temporary directory %s" % self.temp_path) | ||
return self.temp_path | ||
|
||
def __exit__(self, *args): | ||
if self.temp_path: | ||
info("Cleaning up temporary directory %s" % self.temp_path) | ||
try: | ||
shutil.rmtree(self.temp_path) | ||
except OSError as ex: | ||
if ex.errno == errno.EPERM: | ||
err("Failed to rmtree %s" % self.temp_path) | ||
err("Escalating to sudo rm -rf %s" % self.temp_path) | ||
subprocess.check_call( | ||
('sudo rm -rf %s' % self.temp_path).split() | ||
) | ||
else: | ||
raise | ||
self.temp_path = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.