Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
agkyra
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
itminedu
agkyra
Commits
eebcf962
Commit
eebcf962
authored
9 years ago
by
Giorgos Korfiatis
Browse files
Options
Downloads
Patches
Plain Diff
merge scripts and check if app is frozen
parent
3cc90557
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
agkyra/gui.py
+17
-6
17 additions, 6 deletions
agkyra/gui.py
agkyra/protocol.py
+14
-6
14 additions, 6 deletions
agkyra/protocol.py
agkyra/scripts/agkyra
+25
-8
25 additions, 8 deletions
agkyra/scripts/agkyra
agkyra/scripts/gui.py
+0
-46
0 additions, 46 deletions
agkyra/scripts/gui.py
with
56 additions
and
66 deletions
agkyra/gui.py
+
17
−
6
View file @
eebcf962
...
...
@@ -18,17 +18,28 @@ from agkyra.protocol import SessionHelper, launch_server
from
agkyra.config
import
AGKYRA_DIR
from
agkyra.syncer
import
utils
import
subprocess
import
sys
import
os
import
stat
import
json
import
logging
CURPATH
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
getattr
(
sys
,
'
frozen
'
,
False
):
# we are running in a |PyInstaller| bundle
BASEDIR
=
sys
.
_MEIPASS
ISFROZEN
=
True
else
:
# we are running in a normal Python environment
BASEDIR
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
ISFROZEN
=
False
RESOURCES
=
os
.
path
.
join
(
BASEDIR
,
'
resources
'
)
LOG
=
logging
.
getLogger
(
__name__
)
OSX_DEFAULT_NW_PATH
=
os
.
path
.
join
(
CURPATH
,
'
nwjs
'
,
'
nwjs.app
'
,
'
Contents
'
,
'
MacOS
'
,
'
nwjs
'
)
STANDARD_DEFAULT_NW_PATH
=
os
.
path
.
join
(
CURPATH
,
'
nwjs
'
,
'
nw
'
)
RESOURCES
,
'
nwjs
'
,
'
nwjs.app
'
,
'
Contents
'
,
'
MacOS
'
,
'
nwjs
'
)
STANDARD_DEFAULT_NW_PATH
=
os
.
path
.
join
(
RESOURCES
,
'
nwjs
'
,
'
nw
'
)
DEFAULT_NW_PATH
=
OSX_DEFAULT_NW_PATH
if
utils
.
isosx
()
\
else
STANDARD_DEFAULT_NW_PATH
...
...
@@ -45,7 +56,7 @@ class GUI(WebSocketBaseClient):
'
session_file
'
,
os
.
path
.
join
(
AGKYRA_DIR
,
'
session.info
'
))
self
.
start
=
self
.
connect
self
.
nw
=
kwargs
.
get
(
'
nw
'
,
DEFAULT_NW_PATH
)
self
.
gui_code
=
kwargs
.
get
(
'
gui_code
'
,
os
.
path
.
join
(
CURPATH
,
'
nwgui
'
))
self
.
gui_code
=
kwargs
.
get
(
'
gui_code
'
,
os
.
path
.
join
(
RESOURCES
,
'
nwgui
'
))
assert
not
self
.
_gui_running
(
session
),
(
'
Failed to initialize GUI, because another GUI is running
'
)
self
.
_dump_session_file
(
session
)
...
...
@@ -85,9 +96,9 @@ class GUI(WebSocketBaseClient):
LOG
.
debug
(
'
GUI finished, close GUI wrapper connection
'
)
def
run
():
def
run
(
callback
):
"""
Prepare SessionHelper and GUI and run them in the proper order
"""
launch_server
()
launch_server
(
callback
)
LOG
.
info
(
'
Client blocks until session is ready
'
)
session
=
SessionHelper
().
wait_session_to_load
()
assert
session
,
'
UI server failed to load...
'
...
...
This diff is collapsed.
Click to expand it.
agkyra/protocol.py
+
14
−
6
View file @
eebcf962
...
...
@@ -22,6 +22,7 @@ from threading import Thread
import
sqlite3
import
time
import
os
import
sys
import
json
import
logging
import
subprocess
...
...
@@ -29,13 +30,21 @@ from agkyra.syncer import (
syncer
,
setup
,
pithos_client
,
localfs_client
,
messaging
,
utils
)
from
agkyra.config
import
AgkyraConfig
,
AGKYRA_DIR
if
getattr
(
sys
,
'
frozen
'
,
False
):
# we are running in a |PyInstaller| bundle
BASEDIR
=
sys
.
_MEIPASS
ISFROZEN
=
True
else
:
# we are running in a normal Python environment
BASEDIR
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
ISFROZEN
=
False
CURPATH
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)
)
RESOURCES
=
os
.
path
.
join
(
BASEDIR
,
'
resources
'
)
LOG
=
logging
.
getLogger
(
__name__
)
SYNCERS
=
utils
.
ThreadSafeDict
()
with
open
(
os
.
path
.
join
(
CURPATH
,
'
ui_data/common_en.json
'
))
as
f
:
with
open
(
os
.
path
.
join
(
RESOURCES
,
'
ui_data/common_en.json
'
))
as
f
:
COMMON
=
json
.
load
(
f
)
STATUS
=
COMMON
[
'
STATUS
'
]
...
...
@@ -702,14 +711,13 @@ class WebSocketProtocol(WebSocket):
self
.
terminate
()
def
launch_server
():
def
launch_server
(
callback
):
"""
Launch the server in a separate process
"""
LOG
.
info
(
'
Start SessionHelper session
'
)
server_path
=
os
.
path
.
join
(
CURPATH
,
'
scripts
'
,
'
server.py
'
)
if
utils
.
iswin
():
subprocess
.
Popen
([
"
pythonw.exe
"
,
server
_path
],
subprocess
.
Popen
([
callback
,
"
server
"
],
close_fds
=
True
)
else
:
pid
=
os
.
fork
()
if
not
pid
:
os
.
execlp
(
"
python
"
,
"
python
"
,
server
_path
)
os
.
execlp
(
callback
,
callback
,
"
server
"
)
This diff is collapsed.
Click to expand it.
agkyra/scripts/
server.py
→
agkyra/scripts/
agkyra
100644 → 100755
+
25
−
8
View file @
eebcf962
#!/usr/bin/env python
# Copyright (C) 2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
...
...
@@ -16,13 +17,12 @@
import
os
import
sys
SCRIPTSPATH
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
AGKYRAPATH
=
os
.
path
.
dirname
(
SCRIPTSPATH
)
LIBPATH
=
os
.
path
.
dirname
(
AGKYRAPATH
)
try
:
from
agkyra
import
config
except
ImportError
:
sys
.
path
.
insert
(
0
,
"
lib
"
)
from
agkyra
import
config
sys
.
path
.
insert
(
0
,
LIBPATH
)
from
agkyra
import
config
AGKYRA_DIR
=
config
.
AGKYRA_DIR
import
logging
...
...
@@ -35,8 +35,9 @@ HANDLER.setFormatter(FORMATTER)
LOGGER
.
addHandler
(
HANDLER
)
LOGGER
.
setLevel
(
logging
.
INFO
)
CALLBACK
=
os
.
path
.
realpath
(
sys
.
argv
[
0
])
def
main
():
def
run_server
():
from
agkyra.protocol
import
SessionHelper
LOGGER
.
debug
(
'
Start the session helper
'
)
helper
=
SessionHelper
()
...
...
@@ -45,9 +46,25 @@ def main():
helper
.
start
()
else
:
LOGGER
.
info
(
'
Another session is running, aborting
'
)
exit
(
1
)
return
LOGGER
.
debug
(
'
Session Helper is now down
'
)
def
run_gui
():
from
agkyra
import
gui
gui
.
run
(
callback
=
CALLBACK
)
DISPATCH
=
{
'
server
'
:
run_server
,
'
gui
'
:
run_gui
,
}
def
main
():
if
len
(
sys
.
argv
)
>
1
:
arg
=
sys
.
argv
[
1
]
else
:
arg
=
'
gui
'
DISPATCH
[
arg
]()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
agkyra/scripts/gui.py
deleted
100755 → 0
+
0
−
46
View file @
3cc90557
#!/usr/bin/env python
# Copyright (C) 2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
sys
PATH
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
LIBPATH
=
os
.
path
.
join
(
PATH
,
"
lib
"
)
sys
.
path
.
insert
(
0
,
LIBPATH
)
from
agkyra
import
config
AGKYRA_DIR
=
config
.
AGKYRA_DIR
import
logging
LOGFILE
=
os
.
path
.
join
(
AGKYRA_DIR
,
'
agkyra.log
'
)
LOGGER
=
logging
.
getLogger
(
'
agkyra
'
)
HANDLER
=
logging
.
FileHandler
(
LOGFILE
)
FORMATTER
=
logging
.
Formatter
(
"
%(name)s:%(lineno)s %(levelname)s:%(asctime)s:%(message)s
"
)
HANDLER
.
setFormatter
(
FORMATTER
)
LOGGER
.
addHandler
(
HANDLER
)
LOGGER
.
setLevel
(
logging
.
INFO
)
def
main
():
from
agkyra
import
gui
gui
.
run
()
if
__name__
==
"
__main__
"
:
main
()
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