Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH] support: use snakeoil.fileutils.touch
Date: Fri, 09 Oct 2015 01:40:51
Message-Id: 20151008184000.6f4c9059.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] support: use snakeoil.fileutils.touch by Mike Frysinger
1 On Thu, 8 Oct 2015 17:29:12 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > No point in duplicating our own when snakeoil provides a better one.
5 > ---
6 > catalyst/base/resume.py | 5 +++--
7 > catalyst/base/stagebase.py | 6 ++++--
8 > catalyst/support.py | 8 --------
9 > 3 files changed, 7 insertions(+), 12 deletions(-)
10 >
11 > diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
12 > index e3f03e7..443b46d 100644
13 > --- a/catalyst/base/resume.py
14 > +++ b/catalyst/base/resume.py
15 > @@ -15,8 +15,9 @@ import os
16 > import sys
17 > import traceback
18 >
19 > +from snakeoil import fileutils
20 > +
21 > from catalyst.fileops import ensure_dirs, pjoin, listdir_files,
22 > clear_dir -from catalyst.support import touch
23 >
24 >
25 > class AutoResumeError(Exception):
26 > @@ -69,7 +70,7 @@ class AutoResume(object):
27 > myf.write(data)
28 > else:
29 > try:
30 > - touch(fname)
31 > + fileutils.touch(fname)
32 > self._points[point] = fname
33 > except Exception as e:
34 > print AutoResumeError(str(e))
35 > diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
36 > index 813e5f1..f81c51b 100644
37 > --- a/catalyst/base/stagebase.py
38 > +++ b/catalyst/base/stagebase.py
39 > @@ -9,12 +9,14 @@ from stat import ST_UID, ST_GID, ST_MODE
40 > # for convienience
41 > pjoin = os.path.join
42 >
43 > +from snakeoil import fileutils
44 > +
45 > from DeComp.compress import CompressMap
46 >
47 > from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS,
48 > TARGET_MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
49 > from catalyst.support import (CatalystError, msg, file_locate,
50 > normpath,
51 > - touch, cmd, warn, list_bashify, read_makeconf,
52 > read_from_clst, ismount,
53 > + cmd, warn, list_bashify, read_makeconf, read_from_clst,
54 > ismount, file_check)
55 > from catalyst.base.targetbase import TargetBase
56 > from catalyst.base.clearbase import ClearBase
57 > @@ -1513,7 +1515,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
58 > cmd(self.settings["controller_file"]+\
59 > "
60 > build_packages "+mypack,\ "Error in attempt to build
61 > packages",env=self.env)
62 > -
63 > touch(build_packages_resume)
64 > +
65 > fileutils.touch(build_packages_resume)
66 > self.resume.enable("build_packages") except CatalystError:
67 > self.unbind()
68 > diff --git a/catalyst/support.py b/catalyst/support.py
69 > index 1207d36..960a91d 100644
70 > --- a/catalyst/support.py
71 > +++ b/catalyst/support.py
72 > @@ -250,14 +250,6 @@ def
73 > addl_arg_parse(myspec,addlargs,requiredspec,validspec): raise
74 > CatalystError('\n\tAlso: '.join(messages))
75 >
76 > -def touch(myfile):
77 > - try:
78 > - myf=open(myfile,"w")
79 > - myf.close()
80 > - except IOError:
81 > - raise CatalystError("Could not touch "+myfile+".",
82 > print_traceback=True) -
83 > -
84 > def countdown(secs=5, doing="Starting"):
85 > if secs:
86 > print ">>> Waiting",secs,"seconds before starting..."
87
88
89 looks good :)
90
91 --
92 Brian Dolbec <dolsen>