Skip to content

Commit

Permalink
Merge pull request #85 from norkator/ssh-custom-command-logic-issue
Browse files Browse the repository at this point in the history
Ssh custom command logic issue
  • Loading branch information
norkator authored Nov 14, 2021
2 parents 7b909a9 + 2c072dd commit a9e4ece
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
minSdkVersion 22
targetSdkVersion 30

versionCode 49
versionName "1.18.0" // Use Semver
versionCode 50
versionName "1.18.1" // Use Semver
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private void getUPSStatusSSH(

StringBuilder stringBuilder = new StringBuilder();
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(Constants.STATUS_COMMAND_APCUPSD);
((ChannelExec) channel).setCommand(ups.UPS_SERVER_STATUS_COMMAND);
channel.setInputStream(null);
((ChannelExec) channel).setErrStream(System.err);
InputStream input = channel.getInputStream();
Expand Down Expand Up @@ -362,7 +362,7 @@ private void getUPSStatusSSH(
databaseHelper.insertUpdateUps(writablePool, ups.UPS_ID, contentValues);

if (this.taskMode == TaskMode.MODE_ACTIVITY) {
getUPSEvents(writablePool, session, ups.UPS_ID, loadEvents);
getUPSEvents(writablePool, session, ups, loadEvents);
}
} catch (JSchException | IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -409,7 +409,7 @@ private void getUPSStatusAPCUPSD(

// Get ups events
private void getUPSEvents(
SQLiteDatabase writablePool, Session session, final String upsId, final boolean loadEvents
SQLiteDatabase writablePool, Session session, final UPS ups, final boolean loadEvents
) {
ArrayList<String> events = new ArrayList<>();
if (loadEvents) {
Expand All @@ -418,7 +418,7 @@ private void getUPSEvents(
ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
channelSftp.connect();
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
channelSftp.get(Constants.EVENTS_LOCATION, byteArrayOutputStream);
channelSftp.get(ups.UPS_SERVER_EVENTS_LOCATION, byteArrayOutputStream);
BufferedReader bufferedReader = new BufferedReader(new StringReader(byteArrayOutputStream.toString()));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
Expand All @@ -427,7 +427,7 @@ private void getUPSEvents(
bufferedReader.close();
channelSftp.disconnect();
sessionDisconnect(session);
databaseHelper.insertEvents(writablePool, upsId, events);
databaseHelper.insertEvents(writablePool, ups.UPS_ID, events);
} catch (JSchException | IOException | SftpException e) {
e.printStackTrace();
apcupsdInterface.onCommandError(e.toString());
Expand Down

0 comments on commit a9e4ece

Please sign in to comment.