Apple script for plist modify not working in MacOS mavericks - applescript-objc

I just updated my Mac OS to Mavericks and stuck in a issue in my project.
I an updating localization key in plist with apple script. But when I set the localization key plist file goes to 0 KB.
It was working in Mac OS 10.8.
Below is my script to change plist key :
if keyVar as string = "CFBundleLocalizations" then
-- Parse the string for delimiter , and get the array of schemes
set AppleScript's text item delimiters to ","
set theLanguageItems to text items of valVar
-- restore delimiters to previous.if not reset then creats error for below code if we have any property below CFBundleLocalizations propert file.
set AppleScript's text item delimiters to "="
--if there are localization available
if the length of theLanguageItems is greater than 0 then
--create structure for CFBundleLocalizations
tell application "System Events"
set pFile to property list file plistFile
tell pFile
tell contents
--and write to the plist file
--make new property list item with properties {kind:list, value:"theLanguageItems"}
set value of property list item "CFBundleLocalizations" to theLanguageItems
end tell
end tell
end tell
end if

In Mavericks it seems behavior difference for AppleScript, where set value of property list item is not working as expected.
One alternate is to use make new property that you have commented. In this case a new property will be created and appended to the existing one. Hence you need to be careful for that.
Below is actual solution that works for array list
repeat with theCurrentValue in theLanguageItems
make new property list item with properties {kind:string, value:theCurrentValue}
end repeat

Related

How to check if field on desktop application is empty or filled, and if it's filled mark as exception, and if it's empty proceed?

I am new to UI path and am trying to build a workflow/sequence to check if a field in my desktop application is filled or not.
If the field is empty then I want to proceed with the process, and if it is filled I want it to be marked as an exception.
I currently have it so the flow goes as follows:
1. Identified element
2. used Text Exists activity for that field, and I inputed "" as the Text
What are the next steps?
It would be better if you used Get Text command, and using if condition, check if the text is null or empty and take action.
First you want to use Get text on the Text box to extract its contents and store this in a variable in UiPath (Note: if you create the variable from the side properties panel it will give it the type GenericValue, you'll want to change this to String)
Next depends an what you mean by filled:
If you want to accept spaces as been filled then you can use String.IsNullOrEmpty(YOUR_VARIABLE)
If you want the filed to be filled with characters that aren't spaces you can use
String.IsNullOrWhiteSpace(YOUR_VARIABLE)
for your exception it will depend on weather you want to throw it as an
Application exception (new System.Exception("EXCEPTION MESSAGE"))
or
Businessexception (new UiPath.Core.BusinessRuleException("EXCEPTION MESSAGE"))
So your workflow will want to look something like this

Split attribute labels with delimiter for processing

I opened a csv file in Weka 3.8 and selected an attribute/column (picture below). The labels are delimited by a pipe character. There should be 23 distinct labels but Weka displays 914. Thus, Weka cannot visualize for too many values. Action is one label, adventure is another one, etc. Basically there can be more than one label per row.
For processing (eg. classification), How can separate those values so Weka can read them?
This question is similar to this. But the question asks about the date attribute (eg. "dd-MM-yyyy HH:mm"). This asks about a character-separated value (eg. "Action|Adventure|Drama")
Edit:
The data is taken from kaggle.
Ah, I had run into this problem too.
Firstly, ensure that the Genres attribute is recognised as a String type. If you are only using the GUI, go to Open File... and open the file (I presume it's a .dat file. If you've renamed it to .csv hit the check box which says "Invoke options dialog").
In the Generic Object Editor window, enter the index of the Genres attribute (here it's last).
Doing that will cause the attribute to look like this in the GUI.
Now choose the filter called StringToWordVector (weka.filters.unsupervised.attribute.StringToWordVector). Now under the Editor window, find the Tokenizer entry, click on its field, and under delimeters remove the defaults and add the pipe character. You may optionally edit the attribute prefix field as well.
Hit apply and find the required genres added in as numeric attributes, set to 0 for cases where the genre was not present in the original string, 1 otherwise.
StringToWordVector is a pretty useful filter, and there's much more to it in the docs: http://weka.sourceforge.net/doc.dev/weka/filters/unsupervised/attribute/StringToWordVector.html.

How to check a checkbox in a default column list in sharepoint 2013 with powershell?

I have to write a script in powershell, and I'm new to it, to check specific checkbox when a sharepoint site is created. In a list, in sharepoint, we can go to list, change the display, and we can check the columns we want to display in the list.
I have this
$spWeb = Get-SPWeb "http://mysite"
$spList = $spWeb.Lists["MyList"]
$spList.Fields |ft title, internalname, id, type, hidden -AutoSize
I found the ones I want to check (example)
Title InternalName
----- ------------
Created By Author
Modified By Editor
I looked at the properties with
$spList.Fields.GetField("Author")
but I didn't found the property to set the value to true. I also set the checkbox to true in sharepoint, executed the command again and do a compare to see if a property changed, but nothing changed.
I also tried to do :
Update($true)
on the field, on the list.
I want to check those checkbox with a powershell command, I have many lists where I have to do this, and I have to execute that script on many sites.
Thank you for your help
If you need more information, let me know. I didn't found what I was looking for, I tried many things, but nothing worked.
(I couldn't post images..)
After somme research, I found that I have to modify my View. I had some custom columns, so I had some code after that.
$spViews = $spList.Views["All Items"]
After, I did a try/catch statement with this
$spViews.ViewFields.Add($spList.Fields.getField("Author"))
$spViews.Update()
And it worked!
I went on my lists, and all my list were updated with "Created by" "Created" "Modified by" and "Modified". They were displayed in my view list.

Writing value on the current textbox - Selenium

Well I'm facing an issue here:
I use Selenium to automate test on my application, and I use the following code to fill a textbox:
driver.find_element_by_id("form_widget_serial_number").send_keys("example", u'\u0009')
All the textboxes have the same id (form_widget_serial_number) so it's impossible to select a specific textbox by using selection by id (the code above selects the first textbox and u'\u0009' changes the cursor position to the next textbox).
Anyway, how can I send values to the "current" textbox without using find_element_by_id or another selector, given that the cursor is in the current textbox?
There are several selectors available to you - Xpath and css in particular are very powerful.
Xpath can even select by the text of an element and then access its second sibling1:
elem = driver.find_element(:xpath, "//div[contains(text(), 'match this text')]/following-sibling::*[2]")
If you need to find the current element that has focus:
focused_elem = driver.switch_to.active_element
And then to find the next one:
elem_sibling = focused_elem.find_element(:xpath, "following-sibling::*")
Using this example, you could easily traverse any sequence of sequential elements, which would appear to solve your problem.
Take a close look at the structure of the page and then see how you would navigate to the element you need from a reference you can get to. There is probably an Xpath or css selector that can make the traversal across the document.
1 FYI, I'm using an old version of Selenium in Ruby, in case your version's syntax is different
My approach would be:
Get a list of all contemplable elements by the known id
Loop over them until you find a focused element
Use send_keys to write into that element
To get the focused element something like
get_element_index('dom=document.activeElement')
might work. See this question for more information.
Edit: If the list you get from 1. is accidently sorted properly the index of an element in this list might even represent the number of u'\u0009' you have to send to reach that specific element.
Use ActionChains utility to do that. Use following code:
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).send_keys("Hello").perform()

Query to set a value for all items in Amazon SimpleDB

I am trying to to set a value for all items in a domain that do not already have a certain value and have an additional flag set.
Basically for all my items,
SET ValueA to 100 if ValueB is 0
But I am confused about how to achieve this. So far ive been setting the value for individual items by just using a PutRequest like this:
ArrayList<ReplaceableAttribute> newAttributes = new ArrayList<ReplaceableAttribute>();
newAttributes.add(new ReplaceableAttribute("ValueA",Integer.toString(100), true));
PutAttributesRequest newRequest = new PutAttributesRequest();
newRequest.setDomainName(usersDomain);
newRequest.setItemName(userID);
newRequest.setAttributes(newAttributes);
sdb.putAttributes(newRequest);
This works for an individual item and requires me to first get the item name (userID). Does this means that I have to "list" all of my items and do this 1 by 1?
I suppose that since I have around 19000+ items I would also have to use the token to get the next set after the 2000 limit right?
Isn't there a more efficient way? This might not be so heavy right now but I expect to eventually have over 100k items.
PD: I am using the AWS Java SDK for Eclipse.
If you are talking about how you can do it grammatically by writing your own code then Yes. First you have to know all item name i.e in your case UserID and then you need to set a value one by one. You can use BatchPUTAttribute in this case. Using Batch PUT you can update 25 items in one request. You can do 5 to 20 BatchPutAttribute requests in parallel threads. Know more to tune the performance.
If you need to do it somehow in tricky way then you can use SDBExplorer. Please Remember it will set 100 for all items because SDBExplorer does not support conditional PUT. If you would like to set it anyway then Follow these steps-
Download SDBExplorer zip version form download page.
Extract it and run the executable.
Download 30 days trial license.
Once license has been downloaded main UI will open.
Provide valid Access Key and Secret keys and click on "GO" button.
You will see list of domains in Left side tree.
Right click on the domain in which you would like to set value for all item.
Choose "Export to CSV" option.
Export the content of domain into CSV. http://www.sdbexplorer.com/documentation/simpledb--how-to-export-domain-in-csv-using-sdbexplorer.html
Go to path where your domain has exported.
Open CSV file.
Your first column is item name.
Delete all columns other then item Name and column "ValueA".
Set 100 for all item name under "ValueA" column.
Save the CSV.
Go to the SDBExplorer main UI.
Select the same domain.
Click on "Import" option from tool bar.
A panel will open.
Now Import the data into the Domain. http://www.sdbexplorer.com/documentation/simpledb--how-to-upload-csv-file-data-and-specifying-column-as-amazon-simple-db-item-name.html
Once import is done, explore the domain and you will find the value 100 set to all items for column ValueA.
Please try the steps first on any dummy domain.
What exactly I am trying to suggest you?
To know all item name in your domain, I am suggesting you to export all content of your domain into CSV file at local file system. Once you get all item name in CSV, keep only one column "ValueA". Set "100" for all the items in CSV file and upload/import the content back into domain.
Discloser: I am one of the developer of SDBExplorer.