1 |
On Tue, 09 Apr 2019 07:36:45 +0800 |
2 |
Benda Xu <heroxbd@g.o> wrote: |
3 |
|
4 |
> Hi Ethan, |
5 |
> |
6 |
> Ethan Kiang <chocopuff298@×××××.com> writes: |
7 |
> |
8 |
> > diff --git a/porthole/backends/portlandlib.py |
9 |
> > b/porthole/backends/portlandlib.py new file mode 100644 |
10 |
> > index 0000000..c165adb |
11 |
> > --- /dev/null |
12 |
> > +++ b/porthole/backends/portlandlib.py |
13 |
> > @@ -0,0 +1,47 @@ |
14 |
> > +import re |
15 |
> > +import datetime |
16 |
> > +from os import listdir |
17 |
> > +import subprocess |
18 |
> > + |
19 |
> > +EPREFIX = subprocess.check_output(["portageq", "envvar", |
20 |
> > "EPREFIX"]).decode().strip() |
21 |
> |
22 |
> Is it possible that the portage API is used here? |
23 |
> |
24 |
> Benda |
25 |
> |
26 |
> |
27 |
|
28 |
Yes. There is a portage api for this. But the only code really needed |
29 |
from this file is get_compile_time() modified to use code already |
30 |
existing in porthole's portagelib.py |
31 |
|
32 |
brian@professor-x ~ $ python |
33 |
python-exec: Invalid impl in /etc/python-exec/python-exec.conf: python3.4 |
34 |
Python 3.5.7 (default, Mar 25 2019, 08:41:16) |
35 |
[GCC 8.2.0] on linux |
36 |
Type "help", "copyright", "credits" or "license" for more information. |
37 |
>>> import portage |
38 |
>>> portage.const.EPREFIX |
39 |
'' |
40 |
>>> portage.const.EPREFIX or '/' |
41 |
'/' |
42 |
|
43 |
|
44 |
So, depending on what you need use either of the above |