Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
db173453
Commit
db173453
authored
Feb 02, 2014
by
Timur Batyrshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further compatibility with older versions of python-apt (#5853)
parent
fcb760c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
library/packaging/apt
+4
-1
library/packaging/apt_repository
+29
-4
No files found.
library/packaging/apt
View file @
db173453
...
@@ -384,7 +384,10 @@ def main():
...
@@ -384,7 +384,10 @@ def main():
try:
try:
cache = apt.Cache()
cache = apt.Cache()
if p['
default_release
']:
if p['
default_release
']:
apt_pkg.config['
APT
::
Default
-
Release
'] = p['
default_release
']
try:
apt_pkg.config['
APT
::
Default
-
Release
'] = p['
default_release
']
except AttributeError:
apt_pkg.Config['
APT
::
Default
-
Release
'] = p['
default_release
']
# reopen cache w/ modified config
# reopen cache w/ modified config
cache.open(progress=None)
cache.open(progress=None)
...
...
library/packaging/apt_repository
View file @
db173453
...
@@ -70,7 +70,10 @@ apt_repository: repo='ppa:nginx/stable'
...
@@ -70,7 +70,10 @@ apt_repository: repo='ppa:nginx/stable'
'''
'''
import
glob
import
glob
import
json
try
:
import
json
except
ImportError
:
import
simplejson
as
json
import
os
import
os
import
re
import
re
import
tempfile
import
tempfile
...
@@ -110,14 +113,14 @@ class InvalidSource(Exception):
...
@@ -110,14 +113,14 @@ class InvalidSource(Exception):
class
SourcesList
(
object
):
class
SourcesList
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
files
=
{}
# group sources by file
self
.
files
=
{}
# group sources by file
self
.
default_file
=
apt_pkg
.
config
.
find
_file
(
'Dir::Etc::sourcelist'
)
self
.
default_file
=
self
.
_apt_cfg
_file
(
'Dir::Etc::sourcelist'
)
# read sources.list if it exists
# read sources.list if it exists
if
os
.
path
.
isfile
(
self
.
default_file
):
if
os
.
path
.
isfile
(
self
.
default_file
):
self
.
load
(
self
.
default_file
)
self
.
load
(
self
.
default_file
)
# read sources.list.d
# read sources.list.d
for
file
in
glob
.
iglob
(
'
%
s/*.list'
%
apt_pkg
.
config
.
find
_dir
(
'Dir::Etc::sourceparts'
)):
for
file
in
glob
.
iglob
(
'
%
s/*.list'
%
self
.
_apt_cfg
_dir
(
'Dir::Etc::sourceparts'
)):
self
.
load
(
file
)
self
.
load
(
file
)
def
__iter__
(
self
):
def
__iter__
(
self
):
...
@@ -132,7 +135,7 @@ class SourcesList(object):
...
@@ -132,7 +135,7 @@ class SourcesList(object):
if
'/'
in
filename
:
if
'/'
in
filename
:
return
filename
return
filename
else
:
else
:
return
os
.
path
.
abspath
(
os
.
path
.
join
(
apt_pkg
.
config
.
find
_dir
(
'Dir::Etc::sourceparts'
),
filename
))
return
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
_apt_cfg
_dir
(
'Dir::Etc::sourceparts'
),
filename
))
def
_suggest_filename
(
self
,
line
):
def
_suggest_filename
(
self
,
line
):
def
_cleanup_filename
(
s
):
def
_cleanup_filename
(
s
):
...
@@ -176,6 +179,28 @@ class SourcesList(object):
...
@@ -176,6 +179,28 @@ class SourcesList(object):
return
valid
,
enabled
,
source
,
comment
return
valid
,
enabled
,
source
,
comment
@staticmethod
def
_apt_cfg_file
(
filespec
):
'''
Wrapper for `apt_pkg` module for running with Python 2.5
'''
try
:
result
=
apt_pkg
.
config
.
find_file
(
filespec
)
except
AttributeError
:
result
=
apt_pkg
.
Config
.
FindFile
(
filespec
)
return
result
@staticmethod
def
_apt_cfg_dir
(
dirspec
):
'''
Wrapper for `apt_pkg` module for running with Python 2.5
'''
try
:
result
=
apt_pkg
.
config
.
find_dir
(
dirspec
)
except
AttributeError
:
result
=
apt_pkg
.
Config
.
FindDir
(
dirspec
)
return
result
def
load
(
self
,
file
):
def
load
(
self
,
file
):
group
=
[]
group
=
[]
with
open
(
file
,
'r'
)
as
f
:
with
open
(
file
,
'r'
)
as
f
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment