Filter on folder and item type in ArcGIS Online - python-3.x

enter image description hereI want to change the extent of all webmaps in a given folder in ArcGIS Online. However, the standard query command (gis.content.search) does not have a property that allows searching only in a folder.
On the other hand, once I have a list of all items in a given folder, I am unable to only filter all webmaps out. This is the script I used (see also the image):
folderowner = 'my_username'
updatefolder = 'testfolder'
user = gis.user.get(username=my_username)
user
rightFolder = user.items(folder = updatefolder)
rightFolder
for item in rightFolder:
print(item.type)
for item in rightFolder:
if (item_type = "Web Map"):
print (item.title)
screenshot of script
I can print the Item types. But once I try to list only Web Maps, I get a Syntax error. I have tried many different notations.
I can pass the types in a print command, but I can't use the types as a way to filter. Where I am basically looking for is thus a way to get only web maps in a given folder.

Related

Multiple Keywords with same name found but there is only unique keyword

*When i run my robot tests it says Multiple keywords with name 'Set
Variable Value for' found. Give the full name of the keyword you want to use:
step_definitions.Set Variable Value for
variable_handler.Set Variable Value for
It does this for all the keywords mentioned in variable_handler.py
Is there something that i am missing? Do we need to give the name
of python file that has that keyword?*
found not much online. have added the library in the settings.
Variable_handler.py
```#keyword(name='Set Variable Value for')
def Set_Variable_Value_for(tag, value):
my_token_file = 'Resources/written_variables.yml'
data = None
with open(my_token_file, 'r') as testData:
data = yaml.load(testData)
data[tag] = value
with open(my_token_file, 'w') as writeTestData:
print(ruamel.yaml.dump(data, writeTestData,
Dumper=ruamel.yaml.RoundTripDumper))```
step_definitions.py
'''#keyword(name='Set Start Time for Test')
def Test_Start_Time():
tz = timezone('UTC')
Time_Now = datetime.now(tz)
naive_date = Time_Now.replace(tzinfo=None)
Set_Variable_Value_for('START_TIME', naive_date)```
Test.robot
'''Create a New Member
[Documentation] Add a New Member
[Tags] CreateMember MemberAndProjectCreationFlow SanityTest
All
Login to Platform Analytics
Verify Member List Page Elements
Click on Add Member
Add Member Breadcrumb is displayed
Add New Member Details
Verify New Member Creation
Search for the Member ${NEW_MEMBER_NAME_GLOBAL}
Search the Results and Go To ${NEW_MEMBER_NAME_GLOBAL}
${Member_Row_Locator} ${Member_Column}
${MEMBER_HOMEPAGE} = Replace String ${MEMBER_HOME}
MEMBERHOME ${NEW_MEMBER_SCHEMA_GLOBAL}
Set Global Variable ${MEMBER_HOMEPAGE_GLOBAL}
${MEMBER_HOMEPAGE}
🚩Set Variable Value for MEMBER_HOMEPAGE ${MEMBER_HOMEPAGE}
Log To Console Member Creation Successful.```
It should work without specifying the python file that contains
the key word. I have imported all the things required like variable_handler and step definitions
The root of the matter is that you have two or more keywords with the same name imported into the test. When you try to run the keyword Set Variable Value for, robot doesn't know which of the keywords to run. It has no way of knowing if the two names represent two different functions or the same function in two different libraries.
You have three possible solutions:
As the error suggests, you can specify the full path to the keyword, such as step_definitions.Set Variable Value
You tell robot to give precedence to one library over the other using the built-in keyword Set Library Search Order.
You can modify your libraries so that you don't have duplicate keyword names
For more information see Handling keywords with same names in the robot framework user guide.

Dynamically passing a row number to Session.findbyid method

I am trying to write a script which posts invoices in SAP through Excel (fairly new to this), and am running into the following error:
"The control could not be found by id".
The error is coming up at the below line:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,w_counter]").Text = w_glacc
Here, I am trying to pass the GL account number in the first row. There can be multiple rows, so I was hoping that instead of passing ctxtACGL_ITEM-HKONT[1,0]").Text, ctxtACGL_ITEM-HKONT[1,1]").Text etc. I wanted to initialize a counter and pass that value into this method.
Is there any way this can be achieved?
Found a solution:
Instead of passing just w_counter I had to pass "&w_counter&".
Previously, code was:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,w_counter]").Text = w_glacc
Now, it is:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,"& w_counter &"]").Text = w_glacc

Selenium - find element by link text

I am using selenium webdriver on Chrome; python 3 on Windows 10.
I want to scrape some reports from a database. I search with a company ID and a year, the results are a list of links formatted in a specific way: something like year_companyID_seeminglyRandomDateAndDoctype.extension, e.g. 2018_2330_20020713F04.pdf. I want to get all pdfs of a certain doctype. I can grab all links for a certain doctype using webdriver.find_elements_by_partial_link_text('F04') or all of that extension with '.pdf' instead of 'F04', but I cannot figure out a way to check for both at once. First I tried something like
links = webdriver.find_elements_by_partial_link_text('F04')
for l in links:
if l.find('.pdf') == -1:
continue
else:
#do some stuff
But unfortunately, the links are WebElements:
print(links[0])
>> <selenium.webdriver.remote.webelement.WebElement (session="78494f3527260607202e68f6d93668fe", element="0.8703868381417961-1")>
print(links[0].get_attribute('href'))
>> javascript:readfile2("F","2330","2015_2330_20160607F04.pdf")
so the conditional in the for loop above fails.
I see that I could probably access the necessary information in whatever that object is, but I would prefer to do the checks first when getting the links. Is there any way to check multiple conditions in the webdriver.find_elements_by_* methods?
You can try to use below code
links = [link.get_attribute('href') for link in webdriver.find_elements_by_partial_link_text('F04') if link.get_attribute('href').endswith('.pdf")')]
You can also try XPath as below
links = webdriver.find_elements_by_xpath('//a[contains(., "F04") and contains(#href, ".pdf")]')
Andersson's approach seems to work with a slight correction:
if link.get_attribute('href').endswith('.pdf')] rather than if link.get_attribute('href').endswith('.pdf")')], i.e. delete the ").

Netsuite - Transfer Inventory error

I have been using NetSuite for only a short time, and already hate it. I am sorry if this is a stupid question, but I haven't been able to find an answer so far, either in the Netsuite docs, StackOverflow or other websites. In fact, the answers I found have resulted in an error.
My company requires a script to transfer inventory based on an EDI input file. Reading the file is no problem, even parsing it is working. However, actually inserting the data is proving problematic.
I have been able to insert normal records, but Inventory Transfer records are giving me problems.
From Stack Overflow I found and adapted some code into the following:
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
nlapiSelectNewLineItem('invt');
nlapiSetLineItemValue("invt","invtid",1, 189);
nlapiSetLineItemValue("invt","adjustqtyby", 1, "5");
nlapiCommitLineItem('invt');
var id = nlapiSubmitRecord(xfer);
The FormatDate function just exchanges the date from the text file into a system date NetSuite can understand.
However, when I run this code I get the following error:
USER_ERROR: You must enter at least one line item for this transaction.
I thought inserting the line item was the reason to use nlapiSelectNewLineItem, but I guess not. Also nlapiCreateNewLineItem doesn't seem to exist.
The values I am inserting are all just test data, as I'm testing this in the debugger. Location 9 exists, as does item 189.
My full script finds these id's based on string values from the text files. But since this is the section that doesn't work I have set it apart to test.
Can anyone help with this?
You did not specify the type of script you are using, but, looks like you are not setting the fields on the record object, but, setting the value on current record. Below, is the suggested code.
Also, there is no sublist named invt, it should be inventory. Also, there is no field as such invtid, I think most probably you want to setup item, the field Id should be item. You might want to refer SuiteScript Record Browser as well for a help on correct Ids
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
xfer.selectNewLineItem('inventory');
xfer.setCurrentLineItemValue("inventory", "item", 189);
xfer.setCurrentLineItemValue("inventory","adjustqtyby", "5");
xfer.commitLineItem('inventory');
var id = nlapiSubmitRecord(xfer);
If you are using Bin/Lot Numbered Items, please see help topic "Sample Scripts for Advanced Bin / Numbered Inventory Management"

exclude a certain path from all user searches

Unfortunately we have a special folder named "_archive" in our repository everywhere.
This folder has its purpose. But: When searching for content/documents we want to exclude it and every content beneath "_archive".
So, what i want is to exclude the path and its member from all user searches. Syntax is easy with fts:
your_query AND -PATH:"//cm:_archive//*"
to test:
https://www.docdroid.net/RmKj9gB/search-test.pdf.html
take the pdf, put it into your repo twice:
/some_random_path/search-test.pdf
/some_random_path/_archive/search-test.pdf
In node-browser everything works as expected:
TEXT:"HODOR" AND -PATH:"//cm:_archive//*"
= 1 result
TEXT:"HODOR"
= 2 results
So, my idea was to edit search.get.config.xml and add the exclusion to the list of properties:
<search>
<default-operator>AND</default-operator>
<default-query-template>%(cm:name cm:title cm:description ia:whatEvent
ia:descriptionEvent lnk:title lnk:description TEXT TAG) AND -PATH:"//cm:_archive//*"
</default-query-template>
</search>
But it does not work as intended! As soon as i am using 'text:' or 'name:' in the search field, the exclusion seems to be ignored.
What other option do i have? Basically just want to add the exclusion to the base query after the default query template is used.
Version is Alfresco Community 5.0.d
thanks!
I guess you're mistaken what query templates are meant for. Take a look at the Wiki.
So what you're basically doing is programmatically saying I've got a keyword and I want to match the keywords to the following metadata fields.
Default it will match cm:name cm:title cm:description etc. This can be changed to a custom field or in other cases to ALL.
So putting an extra AND or here of whatever won't work, cause this isn't the actual query which will be built. I can go on more about the query templates, but that won't do you any good.
In your case you'll need to modify the search.get webscript of Alfresco and the method called function getSearchResults(params) in search.lib.js (which get's imported).
Somewhere in at the end of the method it will do the following:
ftsQuery = '(' + ftsQuery + ') AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating" AND -TYPE:"st:site"' + ' AND -ASPECT:"st:siteContainer" AND -ASPECT:"sys:hidden" AND -cm:creator:system AND -QNAME:comment\\-*';
Just add your path to query to it and that will do.

Resources