Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 2/4] sync: allow overriding sync-user for the repository
Date: Sun, 07 Dec 2014 07:02:07
Message-Id: 5483FB68.7070107@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 2/4] sync: allow overriding sync-user for the repository by "Michał Górny"
1 On 12/05/2014 04:03 PM, Michał Górny wrote:
2 > + if len(spl) > 1:
3 > + group = spl[1]
4 > + try:
5 > + try:
6 > + # maybe it's a gid?
7 > + gid = int(group)
8 > + except ValueError:
9 > + gp = grp.getgrnam(group)
10 > + else:
11 > + pw = grp.getgrgid(gid)
12
13 Does this behave the same as other tools (like chown) for strings like "12345" ? I vaguely recall
14 someone saying that chown tries a string lookup first, and if that fails then it tries an integer
15 lookup.
16
17 > + except KeyError:
18 > + writemsg("!!! Group '%s' invalid or does not exist\n"
19 > + % group, noiselevel=-1)
20 > + return ()
21 > +
22 > + gr = gp.gr_gid
23 > + else:
24 > + gr = pw.pw_gid
25 > +
26 > + return (pw.pw_uid, gr, pw.pw_dir)
27 > +
28 > + # user or user:group
29 > + (uid, gid, home) = get_sync_user_data(repo.sync_user)
30
31 If it returns () above, this will raise a ValueError, right?
32
33 >>> (x, y, z) = ()
34 Traceback (most recent call last):
35 File "<stdin>", line 1, in <module>
36 ValueError: need more than 0 values to unpack
37
38 Otherwise, LGTM.
39 --
40 Thanks,
41 Zac

Replies