Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar GTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar GTK
Commits
a15aa17a
Commit
a15aa17a
authored
6 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Switch to http polling for startup detection
Reading Briar's output isn't much reliable.
parent
9d8dbb88
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/briar/api/api.py
+16
-10
16 additions, 10 deletions
src/briar/api/api.py
src/briar/gtk/application.py
+1
-2
1 addition, 2 deletions
src/briar/gtk/application.py
with
17 additions
and
12 deletions
src/briar/api/api.py
+
16
−
10
View file @
a15aa17a
...
...
@@ -4,15 +4,17 @@
from
subprocess
import
Popen
,
PIPE
,
STDOUT
from
threading
import
Thread
from
time
import
sleep
from
urllib.error
import
HTTPError
,
URLError
from
urllib.request
import
urlopen
class
Api
:
_process
=
None
def
__init__
(
self
,
headless_jar
,
debug
=
False
):
self
.
_command
=
[
'
java
'
,
'
-jar
'
,
headless_jar
,
'
-v
'
]
self
.
_debug
=
debug
def
__init__
(
self
,
headless_jar
):
self
.
_command
=
[
'
java
'
,
'
-jar
'
,
headless_jar
]
def
has_account
(
self
):
from
pathlib
import
Path
...
...
@@ -52,13 +54,17 @@ class Api:
watch_thread
.
start
()
def
_watch_thread
(
self
,
callback
):
for
line
in
self
.
_process
.
stdout
:
if
self
.
_debug
:
print
(
line
.
decode
(
"
utf-8
"
),
end
=
''
,
flush
=
True
)
# TODO: Sometimes we miss this line (or Briar doesn't send it?)
if
"
Listening on http://localhost:7000/
"
in
line
.
decode
(
"
utf-8
"
):
callback
(
True
)
return
while
self
.
is_running
():
try
:
sleep
(
0.1
)
print
(
urlopen
(
"
http://localhost:7000/
"
).
getcode
())
except
HTTPError
as
e
:
if
(
e
.
code
==
404
):
callback
(
True
)
return
except
URLError
as
e
:
if
not
isinstance
(
e
.
reason
,
ConnectionRefusedError
):
raise
e
callback
(
False
)
def
_login
(
self
,
password
):
...
...
This diff is collapsed.
Click to expand it.
src/briar/gtk/application.py
+
1
−
2
View file @
a15aa17a
...
...
@@ -35,8 +35,7 @@ class Application(Gtk.Application):
styleContext
.
add_provider_for_screen
(
screen
,
cssProvider
,
Gtk
.
STYLE_PROVIDER_PRIORITY_USER
)
self
.
debug
=
True
# TODO: Change this in production
self
.
api
=
Api
(
'
/app/briar/briar-headless.jar
'
,
self
.
debug
)
self
.
api
=
Api
(
'
/app/briar/briar-headless.jar
'
)
def
do_activate
(
self
):
if
self
.
window
is
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment