Commit Graph

31 Commits

Author SHA1 Message Date
Brian C. Lane 9d6211f1b3 Fix unclosed files
Python will eventually close open files, but it is recommended to
explicitly close them instead of waiting for the gc or program exit.

This fixes all the uses of open...read/write in the codebase, mostly in
tests.
2020-10-07 10:51:41 -07:00
Brian C. Lane 0708302464 Use binary mode to tail the file
In python 3 f.seek() on text doesn't work like it does in py2/C because
text is now unicode. So change read_tail to use byte mode and take
unicode into account. Also add tests for it.
2019-07-11 15:16:41 -07:00
Evan Goode 90626f97b6 Return most relevant log file from /compose/log
Return anaconda.log if anaconda is running, composer otherwise

Return packaging.log if it's at least 15s newer than anaconda.log
2019-07-11 15:16:41 -07:00
Brian C. Lane a0aab15311 Ignore a pylint warning about UnquotingConfigParser get args
The args differ, but we are accepting and passing through all args so
it's ok.

Related: rhbz#1613058
2018-09-04 11:16:39 -07:00
Adam Williamson 5c0dfb74e6 Ditch all use of pyanaconda's simpleconfig
lorax uses pyanaconda's SimpleConfigParser in three different
places (twice with a copy that's been dumped into pylorax, once
by importing it), just to do a fairly simple job: read some
values out of /etc/os-release. The only value SimpleConfigParser
is adding over Python's own ConfigParser here is to read a file
with no section headers, and to unquote the values. The cost is
either a dependency on pyanaconda, or needing to copy the whole
of simpleparser plus some other utility bits from pyanaconda
into lorax. This seems like a bad trade-off.

This changes the approach: we copy one very simple utility
function from pyanaconda (`unquote`), and do some very simple
wrapping of ConfigParser to handle reading a file without any
section headers, and returning unquoted values. This way we can
read what we need out of os-release without needing a dep on
pyanaconda or to copy lots of things from it into pylorax.

Resolves: #449
Resolves: #450

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2018-08-30 16:21:09 -07:00
Brian C. Lane de0e662f51 Convert pylorax to python3
Fix up 2to3 complaints. I've decided to do with wrapping list
comprehension inside list() to get the generators to run in several
places instead of list(map( or list(filter( which seem less readable to
me.
2015-05-15 17:11:20 -07:00
Brian C. Lane d25c0b0594 Update copyright statements 2014-05-09 15:13:39 -07:00
Brian C. Lane 6d47689a33 Cleanup pylorax pylint warnings 2014-05-09 08:10:41 -07:00
Will Woods 3a1e176cbb sysutils: add -x to cp in linktree
Since you can't make cross-device links, you'd think that cp -l (make
links) would imply -x (don't cross devices).

You'd be wrong.
2013-03-19 00:47:58 -04:00
Brian C. Lane 43bd549480 add convienience functions for running commands
Adds runcmd() and runcmd_output() which set raise_err=True
2012-09-17 11:26:53 -07:00
Brian C. Lane 12ad7d0d99 restore CalledProcessError handling
When I switched execution over to execWith* functions I failed to
account for the use of CalledProcessError in various places. This
patch restores that behavior. All places that used check_call or
check_output now pass raise_err=True to the execWith* call.
2012-09-17 11:26:50 -07:00
Brian C. Lane 134eec24d5 clean up command execution
Switch to using execWith* so that the command and its output can be
logged. To capture the output setup a logger named "program"

livemedia-creator captures all of this into program.log
2012-07-30 09:22:10 -07:00
Will Woods bdb35b7822 fix remove() on symlink-to-dir 2011-05-31 12:24:17 -04:00
Will Woods 7be79ceba2 Add mvfile() to sysutils
This adds mvfile(), which works basically like cpfile().
2011-05-26 18:14:10 -04:00
Will Woods b436479f97 Add linktree(src, dst) to sysutils 2011-05-12 17:28:53 -04:00
Will Woods cd684d2b3d fixup: add remove to sysutils.__all__ 2011-05-12 17:28:53 -04:00
Will Woods 17c9c8bfaf Remove dead/commented code from __init__ and outputroot
Remove commented-out code, EFI-building code, some redundant comments,
and outputroot.
2011-05-09 15:33:54 -04:00
Will Woods 1e550f8227 Add remove() to sysutils
This adds the remove() function, which works a lot like rm -rf - if you
remove() a file, it uses os.unlink, and if you remove() a directory it
uses shutils.rmtree().
2011-05-09 10:29:00 -04:00
Martin Gracik 98d695f9a2 Add support for ppc
The way we create the images had to be changed a little.
Some code had to be moved to other places, so we can create
images for other architectures too.
2011-03-14 14:01:00 +01:00
Martin Gracik ea6139f125 Fixed pylint errors in sysutils.py 2010-12-02 13:29:55 +01:00
Martin Gracik d888225dd7 Export chown and chmod functions 2010-11-16 12:25:05 +01:00
Martin Gracik 9ec28c1a49 Add chown and chmod functions to sysutils 2010-11-16 09:36:07 +01:00
Martin Gracik e22457b09a Various initrd updates 2010-10-19 17:35:50 +02:00
Martin Gracik 45c5ef566c Experimental single initrd image 2010-10-12 18:32:35 +02:00
Martin Gracik 8034dd06bb Minor changes 2010-08-17 14:14:36 +02:00
Martin Gracik aaef55c007 Fix file trees copying
Create the directories in advance to copying files,
not later, becase this caused some destination path
problems, like not appending the filename to the
destination directory, because it didn't exist.
2010-07-14 15:57:19 +02:00
Martin Gracik ad726c68ec Fix a bug in SmartCopy when printing an error message 2010-02-25 19:36:20 +01:00
Martin Gracik 18ad481067 Improve the error messages in SmartCopy 2010-02-25 19:14:24 +01:00
Martin Gracik a3d550952a Fix the regexp for matching the ld_linux executable.
Remove the double quotes from the resulting match object,
if there is more than one ld_linux file specified.
2010-02-25 18:09:56 +01:00
Martin Gracik 79222bab6c Fix searching for ld_linux executable on 64 bit machines
On some machines we can have more ld_linux executables specified
in /usr/bin/ldd file. This patch fixes how we search for the file.
2010-02-25 17:59:49 +01:00
Martin Gracik a4c638f132 New version 2010-02-23 14:20:05 +01:00