From 630982190b268076a8ba31fa58bcea8baf04bf2f Mon Sep 17 00:00:00 2001 From: Alex Langenfeld Date: Sat, 6 Oct 2018 11:03:21 -0700 Subject: [PATCH] remove OculusDevice Summary: Pretty sure this was meant to get removed before open sourcing, it isn't referenced anywhere. Reviewed By: danielbuechele Differential Revision: D10202081 fbshipit-source-id: 23d213b3a041acad85eb723d32b65f7da276003d --- src/devices/OculusDevice.js | 140 ----------------------------------- src/devices/WindowsDevice.js | 1 - static/icons/oculus.png | Bin 1818 -> 0 bytes 3 files changed, 141 deletions(-) delete mode 100644 src/devices/OculusDevice.js delete mode 100644 static/icons/oculus.png diff --git a/src/devices/OculusDevice.js b/src/devices/OculusDevice.js deleted file mode 100644 index 6bb00ed59..000000000 --- a/src/devices/OculusDevice.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright 2018-present Facebook. - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * @format - */ - -import type {DeviceType, DeviceLogEntry} from './BaseDevice.js'; - -import fs from 'fs-extra'; -import os from 'os'; -import path from 'path'; - -import BaseDevice from './BaseDevice.js'; - -function getLogsPath(fileName: ?string): string { - const dir = '/AppData/Local/Oculus/'; - if (fileName) { - return path.join(os.homedir(), dir, fileName); - } - return path.join(os.homedir(), dir); -} - -export default class OculusDevice extends BaseDevice { - supportedPlugins = ['DeviceLogs']; - icon = 'icons/oculus.png'; - os = 'Oculus'; - - watcher: any; - processedFileMap: {}; - watchedFile: ?string; - timer: TimeoutID; - - constructor(serial: string, deviceType: DeviceType, title: string) { - super(serial, deviceType, title); - - this.watcher = null; - this.processedFileMap = {}; - - this.setupListener(); - } - - teardown() { - clearTimeout(this.timer); - const file = this.watchedFile; - if (file) { - fs.unwatchFile(path.join(getLogsPath(), file)); - } - } - - supportedColumns(): Array { - return ['date', 'tag', 'message', 'type', 'time']; - } - - mapLogLevel(type: string): $PropertyType { - switch (type) { - case 'WARNING': - return 'warn'; - case '!ERROR!': - return 'error'; - case 'DEBUG': - return 'debug'; - case 'INFO': - return 'info'; - default: - return 'verbose'; - } - } - - processText(text: Buffer) { - text - .toString() - .split('\r\n') - .forEach(line => { - const regex = /(.*){(\S+)}\s*\[([\w :.\\]+)\](.*)/; - const match = regex.exec(line); - let entry; - if (match && match.length === 5) { - entry = { - tid: 0, - pid: 0, - date: new Date(Date.parse(match[1])), - type: this.mapLogLevel(match[2]), - tag: match[3], - message: match[4], - }; - } else if (line.trim() === '') { - // skip - } else { - entry = { - tid: 0, - pid: 0, - date: new Date(), - type: 'verbose', - tag: 'failed-parse', - message: line, - }; - } - if (entry) { - this.notifyLogListeners(entry); - } - }); - } - - async setupListener() { - const files = await fs.readdir(getLogsPath()); - this.watchedFile = files - .filter(file => file.startsWith('Service_')) - .sort() - .pop(); - this.watch(); - this.timer = setTimeout(() => this.checkForNewLog(), 5000); - } - - watch() { - const filePath = getLogsPath(this.watchedFile); - fs.watchFile(filePath, async (current, previous) => { - const readLen = current.size - previous.size; - const buffer = new Buffer(readLen); - const fd = await fs.open(filePath, 'r'); - await fs.read(fd, buffer, 0, readLen, previous.size); - this.processText(buffer); - }); - } - - async checkForNewLog() { - const files = await fs.readdir(getLogsPath()); - const latestLog = files - .filter(file => file.startsWith('Service_')) - .sort() - .pop(); - if (this.watchedFile !== latestLog) { - const oldFilePath = getLogsPath(this.watchedFile); - fs.unwatchFile(oldFilePath); - this.watchedFile = latestLog; - this.watch(); - } - this.timer = setTimeout(() => this.checkForNewLog(), 5000); - } -} diff --git a/src/devices/WindowsDevice.js b/src/devices/WindowsDevice.js index 46d031150..75f5f5096 100644 --- a/src/devices/WindowsDevice.js +++ b/src/devices/WindowsDevice.js @@ -9,7 +9,6 @@ import BaseDevice from './BaseDevice.js'; export default class WindowsDevice extends BaseDevice { supportedPlugins = []; - icon = 'icons/oculus.png'; os = 'windows'; constructor() { diff --git a/static/icons/oculus.png b/static/icons/oculus.png deleted file mode 100644 index 4ae24d938a7a15c5ccfa4013e30403842d94181d..0000000000000000000000000000000000000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