diff options
author | bobzel <zzzman@gmail.com> | 2020-02-10 11:39:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 11:39:56 -0500 |
commit | ffeddae0e12719c7bf2a07468822c9547772febc (patch) | |
tree | 7b4ae0842791de8df59d4be59fb5ca964f9d5b09 /src/server/ApiManagers/UtilManager.ts | |
parent | a411e92f6e7b486108f5d06564a2cdbbe91ae5ad (diff) | |
parent | 4adc6b5a343d7ef048354b51444245755759492c (diff) |
Merge pull request #337 from browngraphicslab/new_importer
New importer
Diffstat (limited to 'src/server/ApiManagers/UtilManager.ts')
-rw-r--r-- | src/server/ApiManagers/UtilManager.ts | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index dbf274e93..4cb57a4e7 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -1,10 +1,9 @@ import ApiManager, { Registration } from "./ApiManager"; import { Method } from "../RouteManager"; import { exec } from 'child_process'; -import { command_line } from "../ActionUtilities"; import RouteSubscriber from "../RouteSubscriber"; import { red } from "colors"; -import { main } from "../../scraping/buxton/node_scraper"; +import executeImport from "../../scraping/buxton/final/BuxtonImporter"; export default class UtilManager extends ApiManager { @@ -43,26 +42,7 @@ export default class UtilManager extends ApiManager { register({ method: Method.GET, subscription: "/buxton", - secureHandler: async ({ res }) => { - const cwd = './src/scraping/buxton'; - - const onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); }; - const onRejected = (err: any) => { console.error(err.message); res.send(err); }; - const tryPython3 = (reason: any) => { - console.log("Initial scraper failed for the following reason:"); - console.log(red(reason.Error)); - console.log("Falling back to python3..."); - return command_line('python3 scraper.py', cwd).then(onResolved, onRejected); - }; - - return command_line('python scraper.py', cwd).then(onResolved, tryPython3); - }, - }); - - register({ - method: Method.GET, - subscription: "/newBuxton", - secureHandler: async ({ res }) => res.send(await main()) + secureHandler: async ({ res }) => res.send(await executeImport()) }); register({ |