Class: RUtilAnts::Platform::PlatformInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb,
lib/rUtilAnts/Platforms/i386-cygwin/PlatformInfo.rb,
lib/rUtilAnts/Platforms/i386-mingw32/PlatformInfo.rb,
lib/rUtilAnts/Platforms/i386-mswin32/PlatformInfo.rb,
lib/rUtilAnts/Platforms/x86_64-linux/PlatformInfo.rb

Instance Method Summary collapse

Instance Method Details

#execShellCmdNoWait(iCmd, iInTerminal) ⇒ Object

Execute a Shell command. Do not wait for its termination.

Parameters:

  • iCmd (String): The command to execute

  • iInTerminal (Boolean): Do we execute this command in a separate terminal ?

Return:

  • Exception: Error, or nil if success



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 92

def execShellCmdNoWait(iCmd, iInTerminal)
  rException = nil

  if (iInTerminal)
    # TODO: Handle case of xterm not installed
    if (!system("xterm -e \"#{iCmd}\""))
      rException = RuntimeError.new
    end
  else
    begin
      IO.popen(iCmd)
    rescue Exception
      rException = $!
    end
  end

  return rException
end

#getDiscreteExeExtensionsObject

Return the list of file extensions that might be discretely happened to executable files. This is the optional extensions that can be happened when invoked from a terminal.

Return:

  • list<String>: List of extensions (including .)



42
43
44
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 42

def getDiscreteExeExtensions
  return []
end

#getExecutableExtensionsObject

Get file extensions specifics to executable files

Return:

  • list<String>: List of extensions (including . character). It can be empty.



133
134
135
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 133

def getExecutableExtensions
  return []
end

#getProhibitedFileNamesCharactersObject

Get prohibited characters from file names

Return:

  • String: String of prohibited characters in file names



141
142
143
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 141

def getProhibitedFileNamesCharacters
  return '/'
end

#getSystemExePathObject

Return the list of directories where we look for executables

Return:

  • list<String>: List of directories



25
26
27
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 25

def getSystemExePath
  return ENV['PATH'].split(':')
end

#getSystemLibsPathObject

Return the list of directories where we look for libraries

Return:

  • list<String>: List of directories



50
51
52
53
54
55
56
57
58
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 50

def getSystemLibsPath
  rList = ENV['PATH'].split(':')

  if (ENV['LD_LIBRARY_PATH'] != nil)
    rList += ENV['LD_LIBRARY_PATH'].split(':')
  end

  return rList
end

#launchURL(iURL) ⇒ Object

Execute a given URL to be launched in a browser

Parameters:

  • iURL (String): The URL to launch

Return:

  • String: Error message, or nil if success



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 117

def launchURL(iURL)
  rError = nil

  begin
    IO.popen("xdg-open '#{iURL}'")
  rescue Exception
    rError = $!.to_s
  end

  return rError
end

#osObject

Return the ID of the OS Applications may adapt their behavior based on it.

Return:

  • Integer: OS ID



17
18
19
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 17

def os
  return OS_LINUX
end

#sendMsg(iMsg) ⇒ Object

This method sends a message (platform dependent) to the user, without the use of wxruby

Parameters:

  • iMsg (String): The message to display



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 72

def sendMsg(iMsg)
  # TODO: Handle case of xmessage not installed
  # Create a temporary file with the content to display
  require 'tmpdir'
  lTmpFileName = "#{Dir.tmpdir}/RUA_MSG"
  File.open(lTmpFileName, 'w') do |oFile|
    oFile.write(iMsg)
  end
  system("xmessage -file #{lTmpFileName}")
  File.unlink(lTmpFileName)
end

#setSystemExePath(iNewDirsList) ⇒ Object

Set the list of directories where we look for executables

Parameters:

  • iNewDirsList (list<String>): List of directories



33
34
35
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 33

def setSystemExePath(iNewDirsList)
  ENV['PATH'] = iNewDirsList.join(':')
end

#setSystemLibsPath(iNewDirsList) ⇒ Object

Set the list of directories where we look for libraries

Parameters:

  • iNewDirsList (list<String>): List of directories



64
65
66
# File 'lib/rUtilAnts/Platforms/i386-linux/PlatformInfo.rb', line 64

def setSystemLibsPath(iNewDirsList)
  ENV['LD_LIBRARY_PATH'] = iNewDirsList.join(':')
end