Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
1
Konular (issue)
1
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
inary
Commits
983199b7
Kaydet (Commit)
983199b7
authored
Tem 04, 2019
tarafından
Ali Rıza Keskin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Burdan Süloya selam olsun: Progressbar renklendirmesi ekledim.
üst
52d0c000
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
33 deletions
+56
-33
atomicoperations.py
inary/atomicoperations.py
+15
-7
__init__.py
inary/cli/__init__.py
+3
-3
constants.py
inary/constants.py
+8
-0
fetcher.py
inary/fetcher.py
+20
-21
install.py
inary/operations/install.py
+2
-1
package.py
inary/package.py
+1
-1
util.py
inary/util.py
+7
-0
No files found.
inary/atomicoperations.py
Dosyayı görüntüle @
983199b7
...
...
@@ -74,8 +74,16 @@ opttostr = {INSTALL: "install", REMOVE: "remove", REINSTALL: "reinstall", UPGRAD
class
Install
(
AtomicOperation
):
"""Install class, provides install routines for inary packages"""
def
__init__
(
self
,
package_fname
,
ignore_dep
=
None
,
ignore_file_conflicts
=
None
):
if
not
ctx
.
filesdb
:
ctx
.
filesdb
=
inary
.
db
.
filesdb
.
FilesDB
()
def
__init__
(
self
,
package_fname
,
ignore_dep
=
None
,
ignore_file_conflicts
=
None
,
installdb
=
None
,
filesdb
=
None
):
if
installdb
==
None
:
self
.
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
else
:
self
.
installdb
=
installdb
if
filesdb
==
None
:
self
.
filesdb
=
inary
.
db
.
filesdb
.
FilesDB
()
else
:
self
.
filesdb
=
filesdb
if
not
ctx
.
filesdb
:
ctx
.
filesdb
=
self
.
filesdb
"initialize from a file name"
super
(
Install
,
self
)
.
__init__
(
ignore_dep
)
if
not
ignore_file_conflicts
:
...
...
@@ -91,16 +99,18 @@ class Install(AtomicOperation):
self
.
files
=
self
.
package
.
files
self
.
pkginfo
=
self
.
metadata
.
package
self
.
installedSize
=
self
.
metadata
.
package
.
installedSize
self
.
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
self
.
operation
=
INSTALL
self
.
store_old_paths
=
None
@staticmethod
def
from_name
(
name
,
ignore_dep
=
None
,
packagedb
=
None
,
installdb
=
None
):
def
from_name
(
name
,
ignore_dep
=
None
,
packagedb
=
None
,
installdb
=
None
,
filesdb
=
None
):
if
packagedb
==
None
:
packagedb
=
inary
.
db
.
packagedb
.
PackageDB
()
if
installdb
==
None
:
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
if
filesdb
==
None
:
filesdb
=
inary
.
db
.
filesdb
.
FilesDB
()
# download package and return an installer object
# find package in repository
repo
=
packagedb
.
which_repo
(
name
)
...
...
@@ -141,9 +151,7 @@ class Install(AtomicOperation):
if
cached_file
and
util
.
sha1_file
(
cached_file
)
!=
pkg_hash
:
os
.
unlink
(
cached_file
)
cached_file
=
None
install_op
=
Install
(
pkg_path
,
ignore_dep
)
install_op
=
Install
(
pkg_path
,
ignore_dep
,
installdb
,
filesdb
)
# Bug 4113
if
not
cached_file
:
downloaded_file
=
install_op
.
package
.
filepath
...
...
inary/cli/__init__.py
Dosyayı görüntüle @
983199b7
...
...
@@ -178,13 +178,13 @@ class CLI(inary.ui.UI):
elif
ka
[
'operation'
]
==
"fetching"
:
totalsize
=
'
%.1
f
%
s'
%
util
.
human_readable_size
(
ka
[
'total_size'
])
out
=
'
\r
%-30.50
s (
%
s)
%3
d
%% %9.2
f
%
s
[
%
s]'
%
\
out
=
'
%-30.50
s(
%
s)
%3
d
%% %9.2
f
%
s
[
%
s]'
%
\
(
ka
[
'filename'
],
totalsize
,
ka
[
'percent'
],
ka
[
'rate'
],
ka
[
'symbol'
],
ka
[
'eta'
])
self
.
output
(
out
)
self
.
output
(
'
\r\033
[2K'
+
util
.
colorize_percent
(
out
,
ka
[
'percent'
])
)
util
.
xterm_title
(
"
%
s (
%
d
%%
)"
%
(
ka
[
'filename'
],
ka
[
'percent'
]))
else
:
self
.
output
(
"
\r
%
s (
%
d
%%
)"
%
(
ka
[
'info'
],
ka
[
'percent'
]))
self
.
output
(
"
\r
\033
[2K"
+
colorize_percent
(
"
%
s (
%
d
%%
)"
%
(
ka
[
'info'
],
ka
[
'percent'
]),
ka
[
'percent'
]))
util
.
xterm_title
(
"
%
s (
%
d
%%
)"
%
(
ka
[
'info'
],
ka
[
'percent'
]))
def
status
(
self
,
msg
=
None
,
push_screen
=
True
):
...
...
inary/constants.py
Dosyayı görüntüle @
983199b7
...
...
@@ -157,6 +157,14 @@ class Constants(metaclass=Singleton):
'brightmagenta'
:
"
\033
[01;35m"
,
'brightcyan'
:
"
\033
[01;36m"
,
'brightwhite'
:
"
\033
[01;37m"
,
'backgroundblack'
:
"
\033
[01;40m"
,
'backgroundred'
:
"
\033
[01;41m"
,
'backgroundgreen'
:
"
\033
[01;42m"
,
'backgroundyellow'
:
"
\033
[01;43m"
,
'backgroundblue'
:
"
\033
[01;44m"
,
'backgroundmagenta'
:
"
\033
[01;45m"
,
'backgroundcyan'
:
"
\033
[01;46m"
,
'backgroundwhite'
:
"
\033
[01;47m"
,
'faintblack'
:
"
\033
[02;30m"
,
'faintred'
:
"
\033
[02;31m"
,
'faintgreen'
:
"
\033
[02;32m"
,
...
...
inary/fetcher.py
Dosyayı görüntüle @
983199b7
...
...
@@ -141,7 +141,7 @@ class Fetcher:
self
.
destdir
=
destdir
self
.
destfile
=
destfile
self
.
progress
=
None
self
.
c
=
pycurl
.
Curl
()
self
.
archive_file
=
os
.
path
.
join
(
destdir
,
destfile
or
url
.
filename
())
self
.
partial_file
=
os
.
path
.
join
(
self
.
destdir
,
self
.
url
.
filename
())
+
ctx
.
const
.
partial_suffix
...
...
@@ -164,44 +164,43 @@ class Fetcher:
raise
FetchError
(
_
(
'Access denied to destination file: "
%
s"'
)
%
self
.
archive_file
)
else
:
c
=
pycurl
.
Curl
()
c
.
protocol
=
self
.
url
.
scheme
()
c
.
setopt
(
c
.
URL
,
self
.
url
.
get_uri
())
self
.
c
.
protocol
=
self
.
url
.
scheme
()
self
.
c
.
setopt
(
self
.
c
.
URL
,
self
.
url
.
get_uri
())
# Some runtime settings (user agent, bandwidth limit, timeout, redirections etc.)
c
.
setopt
(
pycurl
.
MAX_RECV_SPEED_LARGE
,
self
.
_get_bandwith_limit
())
c
.
setopt
(
pycurl
.
USERAGENT
,
(
'Inary Fetcher/'
+
inary
.
__version__
)
.
encode
(
"utf-8"
))
c
.
setopt
(
pycurl
.
AUTOREFERER
,
1
)
c
.
setopt
(
pycurl
.
CONNECTTIMEOUT
,
timeout
)
# This for waiting to establish connection
# c.setopt(pycurl.TIMEOUT, timeout) # This for waiting to read data
c
.
setopt
(
pycurl
.
MAXREDIRS
,
10
)
c
.
setopt
(
pycurl
.
NOSIGNAL
,
True
)
self
.
c
.
setopt
(
pycurl
.
MAX_RECV_SPEED_LARGE
,
self
.
_get_bandwith_limit
())
self
.
c
.
setopt
(
pycurl
.
USERAGENT
,
(
'Inary Fetcher/'
+
inary
.
__version__
)
.
encode
(
"utf-8"
))
self
.
c
.
setopt
(
pycurl
.
AUTOREFERER
,
1
)
self
.
c
.
setopt
(
pycurl
.
CONNECTTIMEOUT
,
timeout
)
# This for waiting to establish connection
#
self.
c.setopt(pycurl.TIMEOUT, timeout) # This for waiting to read data
self
.
c
.
setopt
(
pycurl
.
MAXREDIRS
,
10
)
self
.
c
.
setopt
(
pycurl
.
NOSIGNAL
,
True
)
# Header
# c.setopt(pycurl.HTTPHEADER, ["%s: %s" % header for header in self._get_http_headers().items()])
#
self.
c.setopt(pycurl.HTTPHEADER, ["%s: %s" % header for header in self._get_http_headers().items()])
handler
=
UIHandler
()
handler
.
start
(
self
.
archive_file
,
self
.
url
.
get_uri
(),
self
.
url
.
filename
())
if
os
.
path
.
exists
(
self
.
partial_file
):
file_id
=
open
(
self
.
partial_file
,
"ab"
)
c
.
setopt
(
c
.
RESUME_FROM
,
os
.
path
.
getsize
(
self
.
partial_file
))
self
.
c
.
setopt
(
self
.
c
.
RESUME_FROM
,
os
.
path
.
getsize
(
self
.
partial_file
))
ctx
.
ui
.
info
(
_
(
"Download resuming..."
))
else
:
file_id
=
open
(
self
.
partial_file
,
"wb"
)
# Function sets
c
.
setopt
(
pycurl
.
DEBUGFUNCTION
,
ctx
.
ui
.
debug
)
c
.
setopt
(
c
.
NOPROGRESS
,
False
)
c
.
setopt
(
c
.
XFERINFOFUNCTION
,
handler
.
update
)
self
.
c
.
setopt
(
pycurl
.
DEBUGFUNCTION
,
ctx
.
ui
.
debug
)
self
.
c
.
setopt
(
self
.
c
.
NOPROGRESS
,
False
)
self
.
c
.
setopt
(
self
.
c
.
XFERINFOFUNCTION
,
handler
.
update
)
c
.
setopt
(
pycurl
.
FOLLOWLOCATION
,
1
)
c
.
setopt
(
c
.
WRITEDATA
,
file_id
)
self
.
c
.
setopt
(
pycurl
.
FOLLOWLOCATION
,
1
)
self
.
c
.
setopt
(
self
.
c
.
WRITEDATA
,
file_id
)
try
:
c
.
perform
()
self
.
c
.
perform
()
file_id
.
close
()
ctx
.
ui
.
info
(
"
\n
"
)
ctx
.
ui
.
debug
(
_
(
"Downloaded from:"
+
str
(
c
.
getinfo
(
c
.
EFFECTIVE_URL
))))
c
.
close
()
ctx
.
ui
.
debug
(
_
(
"Downloaded from:"
+
str
(
self
.
c
.
getinfo
(
self
.
c
.
EFFECTIVE_URL
))))
self
.
c
.
close
()
except
pycurl
.
error
as
x
:
raise
FetchError
(
"Pycurl.Error: {}"
.
format
(
x
))
...
...
inary/operations/install.py
Dosyayı görüntüle @
983199b7
...
...
@@ -36,6 +36,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
packagedb
=
inary
.
db
.
packagedb
.
PackageDB
()
filesdb
=
inary
.
db
.
filesdb
.
FilesDB
()
A
=
[
str
(
x
)
for
x
in
A
]
# FIXME: why do we still get unicode input here? :/
# A was a list, remove duplicates
...
...
@@ -96,7 +97,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
extra_paths
=
{}
for
x
in
order
:
ctx
.
ui
.
info
(
_
(
"Downloading
%
d /
%
d"
)
%
(
order
.
index
(
x
)
+
1
,
len
(
order
)),
color
=
"yellow"
)
install_op
=
atomicoperations
.
Install
.
from_name
(
x
,
ignore_dep
,
packagedb
,
installdb
)
install_op
=
atomicoperations
.
Install
.
from_name
(
x
,
ignore_dep
,
packagedb
,
installdb
,
filesdb
)
paths
.
append
(
install_op
.
package_fname
)
if
x
in
extra_packages
or
(
extra
and
x
in
A
):
extra_paths
[
install_op
.
package_fname
]
=
x
...
...
inary/package.py
Dosyayı görüntüle @
983199b7
...
...
@@ -109,7 +109,7 @@ class Package:
url
))
raise
else
:
ctx
.
ui
.
info
(
_
(
'{} [cached]'
)
.
format
(
url
.
filename
()),
noln
=
True
)
ctx
.
ui
.
info
(
util
.
colorize
(
_
(
'{} [cached]'
)
.
format
(
url
.
filename
()),
'backgroundblue'
)
)
def
add_to_package
(
self
,
fn
,
an
=
None
):
"""Add a file or directory to package"""
...
...
inary/util.py
Dosyayı görüntüle @
983199b7
...
...
@@ -1048,6 +1048,13 @@ def colorize(msg, color):
else
:
return
str
(
msg
)
def
colorize_percent
(
msg
,
percent
,
color
=
'backgroundgreen'
,
color2
=
'backgroundyellow'
):
if
len
(
msg
)
<
1
:
return
str
(
msg
)
lmsg
=
int
((
len
(
msg
)
*
percent
)
/
100
)
+
1
if
lmsg
>=
len
(
msg
):
return
str
(
ctx
.
const
.
colors
[
color
]
+
msg
+
ctx
.
const
.
colors
[
'default'
])
return
str
(
ctx
.
const
.
colors
[
color
]
+
msg
[:
lmsg
]
+
ctx
.
const
.
colors
[
color2
]
+
msg
[
lmsg
:]
+
ctx
.
const
.
colors
[
'default'
])
def
config_changed
(
config_file
):
fpath
=
join_path
(
ctx
.
config
.
dest_dir
(),
config_file
.
path
)
...
...
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