Pages automation: You don’t have permission - macos

I want to export "pages" file format to "pdf". My JXA script:
function run(argv) {
var pagesApp = Application('Pages');
try{
var doc = pagesApp.open('/Users/testas/Documents/test.pages')
pagesApp.export(doc, {to: '/Users/testas/Desktop/exported.pdf', as: 'PDF'})
} finally {
doc.close({saving: 'no'})
}
}
Running this script with:
osascript -l JavaScript cara.js
Output:
cara.js:135:216: execution error: Error on line 5: Error: The document “test.pages” could not be exported as “exported”. You don’t have permission. (6)
Same result even for the root user. What permission I don't have?

Working example:
function run(argv) {
var pagesApp = Application('Pages')
try{
var doc = pagesApp.open(new Path('/Users/testas/Documents/test.pages'))
pagesApp.export(doc, {to: new Path('/Users/testas/Documents/exported.pdf'), as: 'PDF'})
} finally {
doc.close({saving: 'no'})
}
}

Related

Cypress task with xlsx leads to f.slice when using

I am getting this error when trying to access a cypress task masking the "xlsx": "^0.18.5"
for reading excel files.
From Node.js Internals:
TypeError: f.slice is not a function
at firstbyte (/local0/biologics/gitcheckouts/new-ui-e2e/node_modules/xlsx/xlsx.js:23626:38)
at readSync (/local0/biologics/gitcheckouts/new-ui-e2e/node_modules/xlsx/xlsx.js:23706:14)...
My task looks like this cypress.config.ts
on('task', {
readXlsx: readXlsx.read,
});
If I add brackets after the read:-> readXlsx: readXlsx.read() it already fails when starting cypress with the same error message:
Does anybody know what to do? (Cypress version 12.5.0)
Add on:
import * as fs from 'fs';
private validateExcelFile(countedItems: number, correction: number) {
cy.get('#LASTDOWNLOADEDFILE').then((name) => {
const fileName = name as unknown as string;
cy.log(`Validating excel file: ${fileName}`);
const buffer = fs.readFileSync(fileName);
cy.task('readXlsx', { buffer }).then((rows) => {
const rdw = (rows as string).length;
expect(rdw).to.be.equal(countedItems - correction);
});
});
}
I cannot tell what code, if any, precedes the task. The message seems to indicate a buffer issue, here is my working code you can compare to your own.
Otherwise, suspect the file itself.
import { readFileSync } from "fs";
import { read } from "xlsx/xlsx.mjs";
function read(name) {
const buffer = readFileSync(name);
const workbook = read(buffer);
return workbook
}
...
on('task', {
readXlsx: (name) => read(name)
...

Using this.skip with cypress-json-failed results in: TypeError: Cannot read properties of undefined (reading 'message')

I am attempting to use a global beforeeach() algorithm defined in support/e2e to filter tests. This code works.
beforeEach(function () {
var testSuite = new Array();
testSuite = (Cypress.env('suites'));
if (!testSuite) {
return;
}
const testName = Cypress.mocha.getRunner().test.fullTitle().toLowerCase();
let matches = testSuite.some((value) => {
return (testName.includes(value))
});
if (!matches) {
this.skip();
}
return;
})
However, when using in conjunction with cypress-failed-log, tests that are skipped because of the prior algorithm are failing with this error:
TypeError: Cannot read properties of undefined (reading 'message')
Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
at Context.onFailed (webpack:///./node_modules/cypress-failed-log/src/index.js:136:0)
This is what my plug in looks like. It works independent of the sorting algorithm and fails with the same message even if I only leave just the failed:required line and remove the code that uses the message object.
on('task', {
failed: require('cypress-failed-log/src/failed')()
,
log(message) {
console.log(message)
return null
},
table(message) {
console.table(message)
return null
}
})

Create a file about "DriveApp.createFile"

i try to create a Google-Sheet-File about the command "DriveApp.createFile....". When i run my script i get always the error back "wrong argument".
function myFunction() {
// This command is Running
DriveApp.createFile('New HTML File', '<b>Hello, world!</b>', MimeType.HTML);
// This command is NOT Running
DriveApp.createFile('DOC', 'Hello, world!', MimeType.GOOGLE_SHEETS);
DriveApp.cre
}
Link to the Google-Documentation
Does anyone know where is my fault?
Thanks
DriveApp.createFile() does not support GOOGLE_SHEETS anymore. You can alternatively use DRIVE API to do the same.
var resource = {
title: name,
mimeType: MimeType.GOOGLE_SHEETS,
parents: [{ id: folderId }]
};
var file = Drive.Files.insert(resource);

Why do I get "Uncaught TypeError: navigator.bluetooth.getAvailability is not a function"

The following code, executing on a chromebook with Chrome version 59.0.3071.134 (Official Build) (64-bit) is generating "Uncaught TypeError: navigator.bluetooth.getAvailability is not a function". Any idea why?
bluetoothle.checkBluetoothAvailable = function() {
console.log("checkBluetoothAvailable");
navigator.bluetooth.getAvailability().then(isAvailable => {
document.getElementById('btn_discover').hidden = !isAvailable;
if (!isAvailable) {
document.getElementById('message').innerHTML = 'Bluetooth is not available';
}
});
navigator.bluetooth.addEventListener('availabilitychanged', e => {
document.getElementById('btn_discover').hidden = !e.value;
if (!e.value) {
document.getElementById('message').innerHTML = 'Bluetooth is not available';
} else {
document.getElementById('message').innerHTML = 'Bluetooth is available';
}
});
}
getAvailability is not implemented. It is specified, so it makes sense to try it and expect it to work.
https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md lists what has been implemented in more detail.
And, in the specification you will find the background of some sections such as getAvailability include "This section is not stable." and background text "Unstable".

cannot find the datastore during the compiling in Angular2

When I try to run my page in Wakanda studio 1.1.3, I am getting an error during the compiling when converting the TS to JS. It shows me an error stating "cannot find the datastore"; which is present in my wakanda database. Is anyone else getting the same error?
here is the code:
this.wakanda.catalog.then(ds=>{
ds.TestDatabase.testmethod().then(op=>{
console.log(op);
});
});
my wakanda.service.ts is of the following
import {WakandaClient} from 'wakanda-client/browser/no-promise';
export class Wakanda {
private _client: WakandaClient;
private _catalog;
constructor() {
//this._client = new WakandaClient({ host: 'http://127.0.0.1:8081' });
this._client = new WakandaClient({});
this._catalog = null;
}
get catalog() {
if (!this._catalog) {
return this._client.getCatalog().then(c => {
this._catalog = c;
return c;
});
}
return Promise.resolve(this._catalog);
}
get directory() {
return this._client.directory;
}
get wakandaClientVersion() {
return this._client.version();
}
}
where TestDatavase is a table in my datastore and has a method called testmethod.
[default]
/Users/adithyavinayak/Documents/Wakanda/solutions/TestDatabase/TestDatabase/web/src/app/home/home.component.ts:21:8
Property 'TestDatabase' does not exist on type 'Catalog'. [default]
Checking finished with 4 errors
This one happens even if i make a call to any datastore during compile time.
The solution for this problem is by using the return type of the catalog to any
this.wakanda.catalog.then((ds:any)=>{
ds.TestDatabase.testmethod().then(op=>{
console.log(op);
});
});
This one works without any problem during the time of compilation.

Resources