Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init() {
Logger.info(`${magenta('[DOWNLOADING]')} Figure Map`)
const url = `${flashImagesURL}/gordon/${PRODUCTION}/figuremap.xml`
const figureMap = await Download(url, undefined, { encoding: 'utf8' })
Logger.info(`${magenta('[DOWNLOADING]')}${green('[DONE]')} Figure Map`)
const swfs = await this.parser.parseFigureMap(figureMap)
if (swfs.length > 0) {
const data = await this.extractSWFs(swfs)
await Promise.all(data.map(async data => {
const { name } = data
Logger.info(`${cyanBright('[GENERATING]')}${red('[IMAGES]')} ${name}`)
const { metaData, paths } = await this.generator.generateImages(data)
Logger.info(`${cyanBright('[GENERATING]')}${magentaBright('[METADATA]')} ${name}`)
const furni = furnis[furniId];
console.log(chalk`{blue [Downloading]} ${furni.name} (${furni.classname})`);
try {
await downloadFurni(furni);
} catch (err) {
console.log(chalk`{red [ERROR]} ${furni.name} (${furni.classname}) ${buildFurniUrl(furni.revision, furni.classname)}`);
}
writeFurni(furni);
console.log(chalk`{green [Done]} ${furni.name} (${furni.classname})`);
}
}
Download(Config.furniDataURL, path.join(__dirname, 'raw')).then(() => {
const xml = fs.readFileSync(path.join(__dirname, 'raw', 'furnidata.xml'));
const {roomitemtypes, wallitemtypes} = Parser.parse(xml.toString(), {
attributeNamePrefix : '',
ignoreAttributes: false,
parseAttributeValue: true
}).furnidata;
downloadSWFs(roomitemtypes.furnitype.filter(furni => !furni.classname.includes('*')));
downloadSWFs(wallitemtypes.furnitype);
});
async download(): Promise {
try {
var URLPath = downloadURL.concat(this.revision, '/', this.className, '.swf')
await Download(URLPath).then(data => {
this.extract(data)
})
}
catch(error) {
Logger.error(error)
}
}
private download(): void
{
try
{
var destination = Path.join(__dirname, 'out', this.className)
var filePath = Path.join(destination, this.className.concat('.swf'))
var URLPath = downloadURL.concat(this.revision.toString(), '/', this.className, '.swf')
var exists = IO.existsSync(filePath)
if (!exists)
{
IO.mkdirSync(destination, { recursive: true })
Download(URLPath).then(data =>
{
IO.writeFileSync(filePath, data)
}).catch(error => {
throw error
})
}
}
catch(error)
{
Logger.error(error)
}
}
export default async () => {
if (downloaded) {
return INSTALL_EXTRACT_DIR;
}
const s3 = new S3({ region: process.env.AWS_REGION });
const installationFilesUrl = await s3.getSignedUrlPromise("getObject", {
Bucket: PAGE_BUILDER_S3_BUCKET,
Key: PAGE_BUILDER_INSTALLATION_FILES_ZIP_KEY
});
fs.ensureDirSync(INSTALL_DIR);
fs.writeFileSync(INSTALL_ZIP_PATH, await download(installationFilesUrl));
await extractZip(INSTALL_ZIP_PATH, INSTALL_DIR);
await deleteFile(INSTALL_ZIP_PATH);
return INSTALL_EXTRACT_DIR;
};
public async download(): Promise {
try {
await Download(furnidataURL, { encoding: 'utf8' }).then((data) => {
this.parse(data)
})
}
catch(error) {
Logger.error(error)
}
}
async function handleUrl(fileUrl) {
let tmp = tempfile();
let parsed = url.parse(fileUrl);
let filename = path.basename(parsed.pathname);
let downloaded = await download(fileUrl);
fs.writeFileSync(tmp, downloaded);
checkMimeType(tmp);
return { filename: filename, path: tmp };
}
const init = ()=> {
try {
const config = Meteor.settings;
if (config.configuration && config.configuration["images-folder"] != "") {
configurationFile.imagesFolder = config.configuration["images-folder"].replace(/\/$/, "");
}else{
configurationFile.imagesFolder = join(os.homedir(), "sse-images");
}
if (!existsSync(configurationFile.imagesFolder)){
mkdirSync(configurationFile.imagesFolder);
download("https://raw.githubusercontent.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor/master/private/samples/bitmap_labeling.png", configurationFile.imagesFolder);
download("https://raw.githubusercontent.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor/master/private/samples/pointcloud_labeling.pcd", configurationFile.imagesFolder);
}
if (config.configuration && config.configuration["internal-folder"] != "") {
configurationFile.pointcloudsFolder = config.configuration["internal-folder"].replace(/\/$/, "");
}else{
configurationFile.pointcloudsFolder = join(os.homedir(), "sse-internal");
}
configurationFile.setsOfClassesMap = new Map();
configurationFile.setsOfClasses = config["sets-of-classes"];
if (!configurationFile.setsOfClasses){
configurationFile.setsOfClasses = defaultClasses;
}
configurationFile.setsOfClasses.forEach(o => configurationFile.setsOfClassesMap.set(o.name, o));