Permalink
Browse files

Respect coding style.

  • Loading branch information...
Bofu Chen (bafu)
Bofu Chen (bafu) committed Sep 19, 2017
1 parent c2ad8f2 commit 4539864a8c0c345619f9622de5cdd566ec443bd4
Showing with 47 additions and 47 deletions.
  1. +5 −5 berrynet-manager
  2. +9 −9 client.js
  3. +16 −16 inference/agent.js
  4. +7 −7 inference/classify_server.py
  5. +6 −6 inference/detection_server.py
  6. +4 −4 mail.js
@@ -1,19 +1,19 @@
#! /bin/sh
#
# Copyright 2017 DT42
#
#
# This file is part of BerryNet.
#
#
# BerryNet 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.
#
#
# BerryNet 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 BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -47,4 +47,4 @@ case $1 in
;;
*)
help
esac
esac
@@ -1,14 +1,14 @@
var mqtt = require('mqtt')
//var client = mqtt.connect('mqtt://test.mosquitto.org')
var client = mqtt.connect('mqtt://localhost:1883')
var mqtt = require('mqtt');
//var client = mqtt.connect('mqtt://test.mosquitto.org');
var client = mqtt.connect('mqtt://localhost:1883');
client.on('connect', function () {
client.subscribe('presence')
client.publish('presence', 'Hello mqtt')
})
client.subscribe('presence');
client.publish('presence', 'Hello mqtt');
});
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString())
client.end()
})
console.log(message.toString());
client.end();
});
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet 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.
//
//
// BerryNet 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 BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -54,13 +54,13 @@ client.on('connect', () => {
client.on('message', (t, m) => {
const size = m.length;
const now = moment().format('YYYYMMDD-HHmmss');
const inference_server_img_dir = __dirname + '/image'
const snapshot = `snapshot-${now}.jpg`
const snapshot_path = path.join(inference_server_img_dir, snapshot)
const donefile_path = snapshot_path + '.done'
const resultfile_path = snapshot_path + '.txt'
const resultdonefile_path = snapshot_path + '.txt.done'
const dashboard_image_path = __dirname + '/../dashboard/www/freeboard/snapshot.jpg'
const inference_server_img_dir = __dirname + '/image';
const snapshot = `snapshot-${now}.jpg`;
const snapshot_path = path.join(inference_server_img_dir, snapshot);
const donefile_path = snapshot_path + '.done';
const resultfile_path = snapshot_path + '.txt';
const resultdonefile_path = snapshot_path + '.txt.done';
const dashboard_image_path = __dirname + '/../dashboard/www/freeboard/snapshot.jpg';
log(`inference client: on topic ${t}, received ${size} bytes.`);
@@ -93,7 +93,7 @@ client.on('message', (t, m) => {
fs.readFile(resultfile_path, (err, result) => {
if (err) throw err
watcher.close()
watcher.close();
if (inferenceEngine === 'classifier') {
fs.writeFile(dashboard_image_path, m, (err, written, buffer) => {
@@ -107,15 +107,15 @@ client.on('message', (t, m) => {
console.log('Unknown owner ' + inferenceEngine);
}
client.publish(topicDashboardInferenceResult, result.toString().replace(/(\n)+/g, '<br />'))
client.publish(topicDashboardInferenceResult, result.toString().replace(/(\n)+/g, '<br />'));
})
} else {
console.log('Detect change of ' + filename + ', but comparing target is ' + snapshot + '.txt.done');
}
} else if (eventType == 'rename') {
console.log('watch get rename event for ' + filename)
console.log('watch get rename event for ' + filename);
} else {
console.log('watch get unknown event, ' + eventType)
console.log('watch get unknown event, ' + eventType);
}
})
});
});
@@ -1,17 +1,17 @@
# Copyright 2017 DT42
#
#
# This file is part of BerryNet.
#
#
# BerryNet 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.
#
#
# BerryNet 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 BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -153,7 +153,7 @@ def on_created(self, event):
def main(_):
"""Called by Tensorflow"""
global sess, threads
# Creates graph from saved GraphDef.
@@ -172,7 +172,7 @@ def main(_):
args=(labels,)))
for t in threads: t.start()
for t in threads: t.join()
if __name__ == '__main__':
pid = str(os.getpid())
@@ -188,7 +188,7 @@ def main(_):
logging("model_dir: ", FLAGS.model_dir)
logging("image_dir: ", FLAGS.image_dir)
# workaround the issue that SIGINT cannot be received (fork a child to
# workaround the issue that SIGINT cannot be received (fork a child to
# avoid blocking the main process in Thread.join()
child_pid = os.fork()
if child_pid == 0:
@@ -1,17 +1,17 @@
# Copyright 2017 DT42
#
#
# This file is part of BerryNet.
#
#
# BerryNet 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.
#
#
# BerryNet 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 BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -159,7 +159,7 @@ def main():
_logging('config dir: {}'.format(options['model']))
server(tfnet)
if __name__ == '__main__':
logging.basicConfig(filename='/tmp/dlDetector.log', level=logging.DEBUG)
@@ -174,7 +174,7 @@ def main():
with open(pidfile, 'w') as f:
f.write(pid)
# workaround the issue that SIGINT cannot be received (fork a child to
# workaround the issue that SIGINT cannot be received (fork a child to
# avoid blocking the main process in Thread.join()
child_pid = os.fork()
if child_pid == 0:
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet 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.
//
//
// BerryNet 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 BerryNet. If not, see <http://www.gnu.org/licenses/>.

0 comments on commit 4539864

Please sign in to comment.