Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
0bc670f0
Commit
0bc670f0
authored
Oct 31, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgraded pb lib
parent
7b2b350f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
36 deletions
+45
-36
Gopkg.lock
Gopkg.lock
+2
-2
vendor/gopkg.in/cheggaaa/pb.v1/pb.go
vendor/gopkg.in/cheggaaa/pb.v1/pb.go
+5
-8
vendor/gopkg.in/cheggaaa/pb.v1/pb_x.go
vendor/gopkg.in/cheggaaa/pb.v1/pb_x.go
+35
-25
vendor/gopkg.in/cheggaaa/pb.v1/pool.go
vendor/gopkg.in/cheggaaa/pb.v1/pool.go
+3
-1
No files found.
Gopkg.lock
View file @
0bc670f0
...
...
@@ -471,11 +471,11 @@
[[projects]]
branch = "master"
digest = "1:
3b39cca56c8d1e5a4a16d6c041d183e1ada936d8dd90e0fc24c091f611e08d3d
"
digest = "1:
6744c6d7a97ff6a89a54e88aea6e032dab293c34e8ea7c10a6e8414b65b015b3
"
name = "gopkg.in/cheggaaa/pb.v1"
packages = ["."]
pruneopts = "UT"
revision = "
a3473a4838ba0678c66a8aca05ff97345f81b0ec
"
revision = "
291d751a997645784a6067bc8a4c528e819ee171
"
source = "github.com/cmaglie/pb"
[[projects]]
...
...
vendor/gopkg.in/cheggaaa/pb.v1/pb.go
View file @
0bc670f0
...
...
@@ -13,7 +13,7 @@ import (
)
// Current version
const
Version
=
"1.0.2
5
"
const
Version
=
"1.0.2
6
"
const
(
// Default refresh rate - 200ms
...
...
@@ -296,12 +296,11 @@ func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader {
}
func
(
pb
*
ProgressBar
)
write
(
total
,
current
int64
)
{
pb
.
mu
.
Lock
()
defer
pb
.
mu
.
Unlock
()
width
:=
pb
.
GetWidth
()
var
percentBox
,
countersBox
,
timeLeftBox
,
timeSpentBox
,
speedBox
,
barBox
,
end
,
out
string
pb
.
mu
.
Lock
()
prefix
:=
pb
.
prefix
postfix
:=
pb
.
postfix
// percents
if
pb
.
ShowPercent
{
...
...
@@ -330,7 +329,6 @@ func (pb *ProgressBar) write(total, current int64) {
fromStart
:=
time
.
Now
()
.
Sub
(
pb
.
startTime
)
lastChangeTime
:=
pb
.
changeTime
fromChange
:=
lastChangeTime
.
Sub
(
pb
.
startTime
)
pb
.
mu
.
Unlock
()
if
pb
.
ShowElapsedTime
{
timeSpentBox
=
fmt
.
Sprintf
(
" %s "
,
(
fromStart
/
time
.
Second
)
*
time
.
Second
)
...
...
@@ -373,7 +371,7 @@ func (pb *ProgressBar) write(total, current int64) {
speedBox
=
" "
+
Format
(
int64
(
speed
))
.
To
(
pb
.
Units
)
.
Width
(
pb
.
UnitsWidth
)
.
PerSec
()
.
String
()
}
barWidth
:=
escapeAwareRuneCountInString
(
countersBox
+
pb
.
BarStart
+
pb
.
BarEnd
+
percentBox
+
timeSpentBox
+
timeLeftBox
+
speedBox
+
p
refix
+
postfix
)
barWidth
:=
escapeAwareRuneCountInString
(
countersBox
+
pb
.
BarStart
+
pb
.
BarEnd
+
percentBox
+
timeSpentBox
+
timeLeftBox
+
speedBox
+
p
b
.
prefix
+
pb
.
postfix
)
// bar
if
pb
.
ShowBar
{
size
:=
width
-
barWidth
...
...
@@ -419,13 +417,12 @@ func (pb *ProgressBar) write(total, current int64) {
// check len
out
=
pb
.
prefix
+
timeSpentBox
+
countersBox
+
barBox
+
percentBox
+
speedBox
+
timeLeftBox
+
pb
.
postfix
if
cl
:=
escapeAwareRuneCountInString
(
out
);
cl
<
width
{
end
=
strings
.
Repeat
(
" "
,
width
-
cl
)
}
// and print!
pb
.
mu
.
Lock
()
defer
pb
.
mu
.
Unlock
()
pb
.
lastPrint
=
out
+
end
isFinish
:=
pb
.
isFinish
...
...
vendor/gopkg.in/cheggaaa/pb.v1/pb_x.go
View file @
0bc670f0
...
...
@@ -20,6 +20,7 @@ var (
echoLockMutex
sync
.
Mutex
origTermStatePtr
*
unix
.
Termios
tty
*
os
.
File
istty
bool
)
func
init
()
{
...
...
@@ -28,13 +29,18 @@ func init() {
var
err
error
tty
,
err
=
os
.
Open
(
"/dev/tty"
)
istty
=
true
if
err
!=
nil
{
tty
=
os
.
Stdin
istty
=
false
}
}
// terminalWidth returns width of the terminal.
func
terminalWidth
()
(
int
,
error
)
{
if
!
istty
{
return
0
,
errors
.
New
(
"Not Supported"
)
}
echoLockMutex
.
Lock
()
defer
echoLockMutex
.
Unlock
()
...
...
@@ -51,26 +57,28 @@ func terminalWidth() (int, error) {
func
lockEcho
()
(
shutdownCh
chan
struct
{},
err
error
)
{
echoLockMutex
.
Lock
()
defer
echoLockMutex
.
Unlock
()
if
origTermStatePtr
!=
nil
{
return
shutdownCh
,
ErrPoolWasStarted
}
fd
:=
int
(
tty
.
Fd
())
origTermStatePtr
,
err
=
unix
.
IoctlGetTermios
(
fd
,
ioctlReadTermios
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Can't get terminal settings: %v"
,
err
)
}
if
istty
{
if
origTermStatePtr
!=
nil
{
return
shutdownCh
,
ErrPoolWasStarted
}
fd
:=
int
(
tty
.
Fd
())
origTermStatePtr
,
err
=
unix
.
IoctlGetTermios
(
fd
,
ioctlReadTermios
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Can't get terminal settings: %v"
,
err
)
}
oldTermios
:=
*
origTermStatePtr
newTermios
:=
oldTermios
newTermios
.
Lflag
&^=
syscall
.
ECHO
newTermios
.
Lflag
|=
syscall
.
ICANON
|
syscall
.
ISIG
newTermios
.
Iflag
|=
syscall
.
ICRNL
if
err
:=
unix
.
IoctlSetTermios
(
fd
,
ioctlWriteTermios
,
&
newTermios
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Can't set terminal settings: %v"
,
err
)
}
oldTermios
:=
*
origTermStatePtr
newTermios
:=
oldTermios
newTermios
.
Lflag
&^=
syscall
.
ECHO
newTermios
.
Lflag
|=
syscall
.
ICANON
|
syscall
.
ISIG
newTermios
.
Iflag
|=
syscall
.
ICRNL
if
err
:=
unix
.
IoctlSetTermios
(
fd
,
ioctlWriteTermios
,
&
newTermios
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Can't set terminal settings: %v"
,
err
)
}
shutdownCh
=
make
(
chan
struct
{})
go
catchTerminate
(
shutdownCh
)
return
...
...
@@ -79,16 +87,18 @@ func lockEcho() (shutdownCh chan struct{}, err error) {
func
unlockEcho
()
error
{
echoLockMutex
.
Lock
()
defer
echoLockMutex
.
Unlock
()
if
origTermStatePtr
==
nil
{
return
nil
}
if
istty
{
if
origTermStatePtr
==
nil
{
return
nil
}
fd
:=
int
(
tty
.
Fd
())
fd
:=
int
(
tty
.
Fd
())
if
err
:=
unix
.
IoctlSetTermios
(
fd
,
ioctlWriteTermios
,
origTermStatePtr
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Can't set terminal settings: %v"
,
err
)
}
if
err
:=
unix
.
IoctlSetTermios
(
fd
,
ioctlWriteTermios
,
origTermStatePtr
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Can't set terminal settings: %v"
,
err
)
}
}
origTermStatePtr
=
nil
return
nil
...
...
vendor/gopkg.in/cheggaaa/pb.v1/pool.go
View file @
0bc670f0
...
...
@@ -90,7 +90,9 @@ func (p *Pool) writer() {
// Restore terminal state and close pool
func
(
p
*
Pool
)
Stop
()
error
{
p
.
finishOnce
.
Do
(
func
()
{
close
(
p
.
shutdownCh
)
if
p
.
shutdownCh
!=
nil
{
close
(
p
.
shutdownCh
)
}
})
// Wait for the worker to complete
...
...
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