Merge branch 'devel' of github.com:glenux/qasim into devel
Conflicts: Makefile
This commit is contained in:
commit
9f7c941709
4 changed files with 39 additions and 29 deletions
2
Makefile
2
Makefile
|
@ -119,7 +119,7 @@ clean-lib:
|
||||||
build-lib:
|
build-lib:
|
||||||
|
|
||||||
install-lib:
|
install-lib:
|
||||||
for libfile in $(NAME)/*.rb ; do \
|
for libfile in lib/*.rb lib/**/*.rb ; do \
|
||||||
install -D -o root -g root -m 644 $$libfile $(SHAREDIR)/$(NAME)/$$libfile; \
|
install -D -o root -g root -m 644 $$libfile $(SHAREDIR)/$(NAME)/$$libfile; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,12 @@ end
|
||||||
|
|
||||||
|
|
||||||
module Qasim
|
module Qasim
|
||||||
class QasimGui
|
class QasimApp
|
||||||
|
def initialize
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class QasimGui < QasimApp
|
||||||
|
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -207,32 +212,27 @@ module Qasim
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#
|
def lock_set
|
||||||
#
|
|
||||||
#
|
|
||||||
def run
|
|
||||||
# create lock
|
|
||||||
have_lock = true
|
|
||||||
|
|
||||||
FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR
|
|
||||||
lockfname = File.join APP_CONFIG_DIR, "lock"
|
|
||||||
fd = IO::sysopen( lockfname,
|
|
||||||
Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
|
|
||||||
f = IO.open(fd)
|
|
||||||
f.syswrite( "#{Process.pid}\n" )
|
|
||||||
f.close
|
|
||||||
@app.exec
|
|
||||||
rescue Errno::EEXIST => e
|
|
||||||
# test if the other process still exist
|
|
||||||
masterpid = File.read(lockfname).strip
|
|
||||||
begin
|
begin
|
||||||
|
# create lock
|
||||||
|
have_lock = true
|
||||||
|
|
||||||
|
FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR
|
||||||
|
lockfname = File.join APP_CONFIG_DIR, "lock"
|
||||||
|
fd = IO::sysopen( lockfname,
|
||||||
|
Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
|
||||||
|
f = IO.open(fd)
|
||||||
|
f.syswrite( "#{Process.pid}\n" )
|
||||||
|
f.close
|
||||||
|
rescue Errno::EEXIST => e
|
||||||
|
# test if the other process still exist
|
||||||
|
masterpid = File.read(lockfname).strip
|
||||||
# FIXME: test if the other process exists
|
# FIXME: test if the other process exists
|
||||||
other_path = "/proc/#{masterpid.to_i}"
|
other_path = "/proc/#{masterpid.to_i}"
|
||||||
if File.exists? other_path then
|
if File.exists? other_path then
|
||||||
cmdline = File.read( File.join( other_path, 'cmdline' ) )
|
cmdline = File.read( File.join( other_path, 'cmdline' ) )
|
||||||
if cmdline =~ /qasim/ then
|
if cmdline =~ /qasim/ then
|
||||||
warn "error: Another instance of %s is already running." % APP_NAME
|
raise LockError, "Another instance of %s is already running." % APP_NAME
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fd = IO::sysopen( lockfname,
|
fd = IO::sysopen( lockfname,
|
||||||
|
@ -240,15 +240,26 @@ module Qasim
|
||||||
f = IO.open(fd)
|
f = IO.open(fd)
|
||||||
f.syswrite( "#{Process.pid}\n" )
|
f.syswrite( "#{Process.pid}\n" )
|
||||||
f.close
|
f.close
|
||||||
@app.exec
|
|
||||||
end
|
end
|
||||||
ensure
|
end
|
||||||
|
|
||||||
|
def lock_unset
|
||||||
masterpid = File.read(lockfname).strip
|
masterpid = File.read(lockfname).strip
|
||||||
if masterpid.to_i == Process.pid then
|
if masterpid.to_i == Process.pid then
|
||||||
FileUtils.rm lockfname
|
FileUtils.rm lockfname
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
def run
|
||||||
|
lock_set
|
||||||
|
@app.exec
|
||||||
|
ensure
|
||||||
|
lock_unset
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
clean:
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ module Qasim
|
||||||
#rdebug "Config: #{@config_dir}/config"
|
#rdebug "Config: #{@config_dir}/config"
|
||||||
|
|
||||||
@maps = []
|
@maps = []
|
||||||
Find.find( @config_dir, APP_SYSCONFIG_DIR ) do |path|
|
map_dirs = [@config_dir, APP_SYSCONFIG_DIR].select{ |d|
|
||||||
|
File.exists? d and File.directory? d
|
||||||
|
}
|
||||||
|
Find.find( *map_dirs ) do |path|
|
||||||
if File.file? path
|
if File.file? path
|
||||||
if File.basename( path ) =~ /.map$/
|
if File.basename( path ) =~ /.map$/
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in a new issue