Running Telnet with automator
I am a recent Mac convert so excuse me if I am looking in the wrong place.
I have a networked Tivo and run an executable called 'vserver' in order to run a Mac prog called Tivotool. Currently I enter these commands (from my Windows box - I haven't got to grips with telnet on my Macbook yet):
telnet 192.168.0.200
cd /var/hack/bin
./vserver
Can I script this in Automator?
I am grateful for your help,
Gary
Macbook Mac OS X (10.4.8)
Hello,
Yes I tried the same with SSH and the activity still fails.
I also tried pwershell script, however the .Net Activity fails saying telnet is unrecognized command.
So how are we to achieve telnet commands using SSH or Run Program Activity.
Is it supported in the first place ? If I only have a run program activity to telnet and I try to capture the output in a text file, I see that the telnet session itself fails and the exit code is -1.
If I use something like dir or ipconfig/flushdns etc they all return exit code of 0.
Moreover, for telnet sessions since it will be based on a unique process ID, how can we configure the next set of command using the same ID ?
Regards,
Abdul Karim. (http://sites.google.com/site/scomblogs Twitter:@Abdul_SCOM)
Similar Messages
-
HT2488 Find/Replace text in document with automator: any suggestions?
I'm looking to replace a number of unique html tags for a number of documents: is there any way to do this without going through the documents one-by-one, tag-by-tag? I would imagine I might be able to do something with automator, but I'm open to any other suggestions. I have some knowledge of html, but that's about it.
So I take it this is something you do regularly, not something that needs to get done once? if it were a oneshot operation it would be simpler to use TextWrangler.
For repeated use, the simplest approach is to run through the files and apply text item delimiters to each tag:
set indesignTags to {"idtag1", "idtag2", "idtag3"}
set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
repeat with aFile in theFiles
-- get file text
set fileText to read aFile
-- swap tags
repeat with i from 1 to count of indesignTags
-- swap lead tags
set fileTextBits to tid({input:fileText, delim:"<" & item i of indesignTags})
set fileText to tid({input:fileTextBits, delim:"<" & item i of htmlEquivs})
-- swap trailing tags
set fileTextBits to tid({input:fileText, delim:"</" & item i of indesignTags})
set fileText to tid({input:fileTextBits, delim:"</" & item i of htmlEquivs})
end repeat
-- make new file path with html extension
set oldFilePath to POSIX path of aFile
set filePathBits to tid({input:oldFilePath, delim:"."})
set last item of fileNameBits to "html"
set newFilePath to tid({input:filePathBits, delim:"."})
-- save at new file path
set fp to open for access newFilePath with write permission
write fileText to fp
close access fp
end repeat
on tid({input:input, delim:delim})
-- handler for text items
set {oldTID, my text item delimiters} to {my text item delimiters, delim}
if class of input is list then
set output to input as text
else
set output to text items of input
end if
set my text item delimiters to oldTID
return output
end tid
This will work if the indesign tags are unique and there is no complex syntax. It might fail if tags have overlapping names (e.g. "<bl>" and "<blue>") or if there's any irregular notation. If you need more sophisticated handling you'll have to use regular expressions. In that case, download and install the Satimage osax from this page, and use the following (similar) code:
set indesignTags to {"idtag1", "idtag2", "idtag3"}
set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
-- set up regular expressions change lists
set findList to {}
set changeList to {}
repeat with i from 1 to count of indesignTags
set end of findList to "(</?)" & item i of indesignTags & "(?![[:alnum:]])"
set end of changeList to "\\1" & item i of htmlEquivs
end repeat
set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
repeat with aFile in theFiles
-- get file text
set fileText to read aFile
-- swap tags - needs Satimage osax
set fileText to change findList into changeList in fileText with regexp
-- make new file path with html extension - needs Satimage osax
set oldFilePath to POSIX path of aFile
set newFilePath to change "\\.[^.]+$" into ".html" in oldFilePath with regexp
-- save at new file path
set fp to open for access newFilePath with write permission
write fileText to fp
close access fp
end repeat
Message was edited by: twtwtw - I made an error in the second regular expression. should be "\\.[^.]+$", not "\\..*$". fixed in text. -
Win7 problem with Telnet with IE8 (32 bit version)
We are not able to run Telnet in Win7 (64bit) with IE8 (32 bit ) (example:
telnet://ip), but it works with 64bit IE8.
Any solution?
Thanks
BahramTo enable Telnet client functionality in win 7, 64 bit, with IE 8 ,32 bit, please follow these instructions:
1-Open the telnet client in control panel.
A) Go to Control Panel
B) Point to Programs And Features
C)Click Turn Windows features on or off
D)Check Telnet Client
E)Hit OK
2-
Copy the 64 bit version of telnet.exe from %windir%\System32 to %windir%\SysWOW64
3- Add the following registry key for the 32 bit version of IE
Open Regedit.exe and navigate to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_DISABLE_TELNET_PROTOCOL
Backup to original key by right clicking “FEATURE_DISABLE_TELNET_PROTOCOL” and selecting export.
Save the key to a location where you can easily locate the file if it needs to be restored.
If this key does not exist, please add the Key as named above.
4- Right click “FEATURE_DISABLE_TELNET_PROTOCOL” again and select “New” and “DWORD (32-bit) Value” from the menu.
In the right pane, name the new value “iexplore.exe”.
Verify that the value for iexplore.exe is 0x00000000 and then close regedit.exe.
5- Copy
%windir%\system32\en-US\telnet.exe.mui to %windir%\SysWOW64\en-US -
Right-Click Services with Automator
So I still have my Macbook Pro that I haven't upgraded but I did update my iMac to Mavericks, so far everything is working well except that I used to have a Batch Rename Service that I used quite often but now when I right click with my mouse the Batch Rename services I created with Automator doesn't show up. I tried recreating it but still nothing. I went back to my Mountain Lion laptop and it works just fine. Any ideas?
I too was having this problem. I did the following, and it seamed to get it going:
moved the service out of the services folder (~/Library/Services/) to an easy place to get to (Desktop).
In Automator, open an new document, and selcted iCould.
drag the service from the desktop to iCloud
opened it, from iCould
file -> convert to...
select service and give it a different name than the orignal.
save and exit.
service should now be available.
In my case, the service only runs on my mac hdd. I have not yet found how to get service to run on a connected drive as it did in Mountain Lion. I want to run the service on my netowrk drive from my Synology NAS box.
Hope this helps a little -
LMS 3.2 and RME 4.3.1 telnet with tacacs+ fails
Hi everyone,
I'm having issue with credentials verification for telnet with TACACS+ enabled. Verification job fails with "Telnet: Incorrect" and an exception to daemons.log:
om.cisco.nm.lib.cmdsvc.CmdSvcException: com.cisco.nm.lib.cmdsvc.telnet.TelnetException: Unable to read from socket
at com.cisco.nm.lib.cmdsvc.TelnetSession.connect(TelnetSession.java:89)
at com.cisco.nm.lib.cmdsvc.Session.connect(Session.java:152)
at com.cisco.nm.lib.cmdsvc.AuthHandler.connect(AuthHandler.java:254)
at com.cisco.nm.lib.cmdsvc.OpConnect.invoke(OpConnect.java:56)
at com.cisco.nm.lib.cmdsvc.SessionContext.invoke(SessionContext.java:299)
at com.cisco.nm.lib.cmdsvc.Engine.process(Engine.java:57)
at com.cisco.nm.lib.cmdsvc.LocalProxy.process(LocalProxy.java:22)
at com.cisco.nm.lib.cmdsvc.CmdSvc.connect(CmdSvc.java:190)
at com.cisco.nm.lib.cmdsvc.CmdSvc.connect(CmdSvc.java:166)
at com.cisco.nm.xms.xdi.pkgs.LibDcma.persistor.CliOperator.<init>(CliOperator.java:214)
at com.cisco.nm.xms.xdi.pkgs.SharedDcmaIOS.transport.IOSCliOperator.<init>(IOSCliOperator.java:116)
at com.cisco.nm.xms.xdi.pkgs.SharedDcmaIOS.transport.CatIOSSwitchCliOperator.<init>(CatIOSSwitchCliOperator.java:56)
at com.cisco.nm.xms.xdi.pkgs.SharedDcmaIOS.transport.Cat6kIOSCliOperator.<init>(Cat6kIOSCliOperator.java:32)
at com.cisco.nm.xms.xdi.pkgs.SharedDcmaIOS.transport.Cat6kIOSConfigOperator.getOperator(Cat6kIOSConfigOperator.java:35)
at com.cisco.nm.xms.xdi.pkgs.LibDcma.persistor.OperatorCacheManager.getOperatorForDevice(OperatorCacheManager.java:50)
at com.cisco.nm.xms.xdi.pkgs.LibDcma.persistor.ConfigOperation.doConfigOperation(ConfigOperation.java:99)
at com.cisco.nm.xms.xdi.pkgs.SharedDcmaIOS.transport.IOSConfigOperator.fetchConfig(IOSConfigOperator.java:73)
at com.cisco.nm.rmeng.dcma.configmanager.ConfigManager.updateArchiveForDevice(ConfigManager.java:658)
at com.cisco.nm.rmeng.dcma.configmanager.ConfigManager.performCollection(ConfigManager.java:1646)
at com.cisco.nm.rmeng.dcma.configmanager.CfgUpdateThread.run(CfgUpdateThread.java:27)
I've tried to edit TacacsPrompts.ini also with suggestion to enter "," after last space character
I'm using only TACACS so all prompts are the same. I'm using MOTD also.
TACACS prompt looks like this example : "TEST username: ,TEST password: " so this looks obvious.
The issue started to appear after some patching done to RME and CiscoView, but I'm not sure that this is connected anyhow.
Thanks for all the helpHi!
They gave me the solution like this:
line vty
timeout login response 90
Ofcourse it helped but this it still inproper behavior from LMS side. It sends the username char by char for more than a minute! Guess the scenario with thousands of devices.... It will take ages to telnet to them. And network performance has nothing to do with that - i'm running the LMS on a powerful Sun and the network is mostly gigabit connected.
Setting timeout login response is a workaround but does not fix the problem.
Still waiting fot some fix to LMS not for fairly acceptable workarounds.
This is NOT case with TACACS enabled on a router. The box responds within moment when telneted using commandline or other NMS software. This is a problem with LMS telnet login mechanism and prompt parsing (TacacsPrompts.ini doesn't seem to work at all, I could type there anything and it has no effect on the login proces).
Besides this SSH to the same box wit TACACS works flawlessly. But then it parses only password prompt not the username - this is sent by ssh. -
Issue with Automator and Circus Ponies Notebooks
I have not found an Automator specific discussion, so let me know if there is somewhere else I should post this.
I have created a limited backup program with Automator. It begins with "Get Specified Finder Items". The second step is "Copy Finder Items". I kept getting messages that it could not backup various Notebooks because it couldn't copy certain Notebook files. The issues were always with something in a Notebook .../Attachments/ that ended with the extension .moddates.
Using PathFinder 5, I would right click and select Show Package Contents. I found numerous "contents.old.plist" files in these Notebooks which I deleted. I would try again and it would be another issue, but always with a Notebook file. In some other cases I found things in the attachments folder which I deleted, one of which was a .jpg of a screenshot of a a 'page' in Things. Two others were .eml files.
I thought these actions would correct the issue, but now it seems that there is no end to this issue. Using PathFinder 5, show invisibles, and show package contents I see a .moddates file, but do not want to delete it.
My next attempt at resolving this was to used PathFinder to just copy the Notebook directory directly to my Flash Drive which is formatted as Mac OS Extended (Journaled) or HFS+. There was no problem copying the files this way, so I am wondering if the problem could be with Automator.The way that you are getting the value of the variables will only work in an Automator workflow, since that terminology is from Automator's scripting dictionary. If the workflow is saved as an application or is otherwise run outside of the Automator environment (i.e. no workflow window), another method will need to be used to retrieve the variables, such as preceding *Get Value of Variable* actions, a temporary file, or user defaults.
If you aren't using any other input items, for example, you can use something like:
1) *Get Value of Variable* { Variable: ProjectName } (Ignore Input)
2) *Get Value of Variable* { Variable: ProjectManager }
3) *Get Value of Variable* { Variable: RegionManager }
4) *Get Value of Variable* { Variable: Partner }
5) *Get Value of Variable* { Variable: TodayDate }
6) *Run AppleScript*:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}
set ProjectName to (first item of the input) as text
set ProjectManager to second item of the input
set RegionManager to third item of the input
set Partner to fourth item of the input
set TodayDate to (fifth item of the input) as text
-- rest of script
end run
</pre> -
Is this feasible with Automator?
I am tasked with the project of making it possible for Mac users in an office to create several folders and documents automatically, at the click of a mouse, if you will. Can this be done with Automator? If not, any recommendations on how to make this happen?
Example:
Law office has a new client. By simple act of automation, it would be great if a folder was created with the clients' name, followed by a subfolders, with boiler plate documents inside them that are used in every case, such as contracts, introductory letters, motions, etc. Even more ideal, it would be great to have a checklist of all the steps that is generated, and even more ideal, would be great if the user could choose the type of case, and have folders and letters generated based on the choice of which kind of case.
Is this possible?It is possible - a service can be used to run a workflow with folders selected in a Finder window. There are a few ways to create the folder structures, one would be to use a previously created template and copy that to the new client folder - I have written an Automator action that does just that:
The Copy Folder Structure action can be downloaded here. -
Possible to change mouse sensitivity with automator?
For regular computing, I use my magic mouse. For gaming, I use a different mouse with more controls.
Each time I switch between mice, I have to change the mouse sensitivity under system preferences. I'd like to autmoate this with a hot key. Possible to do with automator?OK, found a nifty applescript for this. Just change the 5 in the first line to 0-9, depending on what you want to set the mouse sensitivity to be. I created another script which increases mouse sensitivity. Then I created a hotkey combination to change my mouse sensitivity settings very quickly based on which mouse I'm using.
If you don't know how to set this script up, follow the instructions in this helpful comment here: https://discussions.apple.com/thread/2488007?start=0&tstart=0. But instead of having the application run in just iTunes, as the comment suggests, have it run in "all applications."
Here's the script:
set trackingValue to 5
--Open and activate System Preferences
tell application "System Preferences" to activate
--Attempt to change settings using System Events
tell application "System Events"
tell process "System Preferences"
try
--Open the "Keyboard & Mouse" pane
click menu item "Mouse" of menu "View" of menu bar 1
delay 2
set value of slider "Tracking Speed" of window "Mouse" to trackingValue
--end tell
on error theError
--An error occured
display dialog ("Sorry, an error occured while altering Keyboard and Mouse settings:" & return & theError) buttons "OK" default button "OK"
end try
end tell
end tell -
Issue with folder action created with automator
Hello all,
I'm having an issue with folder actions that i created with automator and it's driving me crazy. Apple says they can't help with things created by the user so this is my only shot at figuring this out.
Running a Mini 2.3G quad i7, 8GB ram on OSX Mavericks 10.9.2
My goal is to set up an action to add text to the filename of a file placed into a particular folder. So I open automator and choose folder action. Then I choose the folder I want the action applied to at the top. Then I go to Files and Folders in the library and choose rename finder items and drag it over to the workflow. I select add text, then add the text I want added to the file name and choose before name because I want the added text to preceede the original filename text. I save it then go to the folder I applied it to and right clikc go to services then folder actions and verify that the service is attached to that particular folder and it is.
Should work right? No. When I place a file in that folder the action runs and adds the text like I want it to... but then it starts to add it over and over again in an infinite loop. It also adds a file with the extension .ds_store to the folder that also has the name added over and over.
I've tried deleteing all the folder actions and even deleteing all the folder actions themselves saved by the automator in the workflow file in the user library.
I'm stumped... no idea what to do. A while ago I had used the automator to batch rename files and it worked perfectly. I tried the same steps i listed above to set this action up on a machine in an Apple retail store and it worked... so I know I have the set up right.
Any help is greatly appreciated.
Thanks,
JustinHi JK257
This is why it happens:
The folder action is looking for new items in the folder. You drop in a file called "File1". So it renames it "sometext File1". Then it sees this new file called "sometext File1" and thinks "Hey, this is a new file - I'll call it 'sometext sometext File1' because I have to rename every new file." Then it sees this new file called "sometext sometext File1" and thinks...
You get the picture.
(the .ds_store is a normally hidden database file which is getting revealed by the same process.)
The solution is to move the files out of the renamer folder into a receiving folder after they have been renamed:
Hope this helps,
H -
Multi batch renaming with automator
Hi, everybody!
Hope I can find help in this section. Else, please forgive me if I posted in the wrong place...
I find myself in this situation.
I have many pdf's I need to transform into JPG's, but of course I need the name to be "meaningful". Each pdf contains 30 to 100 "sheets", that is to say it will produce from 30 to 100 jpgs
No problem with Automator and pdf-to-jpg.
Original pdf name: meaningless (something like "Scan_01")
JPG needed format: PREF_XXXXXX_EYY_S#
prefix is (by now) fixed: MAD
XXXXXX : a 6-digit progressive number BUT it has to increase each 4 jpg's
EYY: a progressive number that could be even set by hand, as it indicates the "Envelope" from which pdf's were scanned
S# : a number ranging from 1 to 4
Just to be clear (I hope), here is an example of how a correct output should look like:
MAD_123456_E01_S1
MAD_123456_E01_S2
MAD_123456_E01_S3
MAD_123456_E01_S4
MAD_123457_E01_S1
MAD_123457_E01_S2
MAD_123457_E01_S3
MAD_123457_E01_S4
MAD_123458_E01_S1
and so on.
Of course the point is not to prepend "MAD_" or whatever, and the "EYY" thing can go anywhere in the name (even after "MAD_"): I really don't know how to set a counter to switch from xxxxx1 to xxxxx2 each time S# reaches "S4" and, meanwhile, to reset "S#" to "S1".
Any advice on how to do that?If I understand you correctly, you have a bunch of files that have been converted to jpg, and just want to rename them starting with a specified sequence. The folowing Run AppleScript added to your workflow should be close - it extracts the name pieces from a dialog so that they can be manipulated and reassembled. There isn't any error checking, it just assumes the format of the name is the same as the default answer:
property divider : "_" -- the character dividing the name pieces
on run {input, parameters}
set output to {}
set theAnswer to text returned of (display dialog "Enter starting sheet name:" default answer "MAD_123456_E01_S1")
# break the name apart at divider - format is assumed to be the same as the default answer
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, divider}
set {prefix, survey, envelope, page} to text items of theAnswer
set AppleScript's text item delimiters to tempTID
# extract numbers
set envelope to text -2 thru -1 of envelope
set page to (text -1 of page) - 1
repeat with anItem in the input
set page to page + 1
if page > 4 then
set page to 1
set survey to survey + 1
end if
set theEnvelope to "E" & text -2 thru -1 of ("00" & envelope) -- leading zero
set thePage to "S" & page
tell application "Finder"
set name of anItem to prefix & divider & survey & divider & theEnvelope & divider & thePage & ".jpg"
set end of output to anItem as alias
end tell
end repeat
return output
end run
Edit: I am a he, by the way. -
Moving files to the Trash with Automator
I'm having some problems with Automator, and I'm hoping it's just a simple step I'm missing.
I have a list (text file) of a group of files I wish to remove from a folder (about 650 or so files, from a folder of about 8000). I have been able to get Automator to read the text file, and show me the result.
(Ask for Finder Items (Files & Folders), Combine Text Files (Text), Filter Paragraphs [Return Paragraphs That Are Not Empty] (text))
This results in showing me my list of files I wish to remove.
I don't quite get how to pass this list on to the Finder to tell it to select these files, and move them to the trash.
Any assistance would be appreciated.Since your text file just has the names, an action is needed to build the complete file path. Most of Apple's text and file actions don't use variables, but a Run AppleScript action can be used to fill in the blank. Give this workflow a try (I haven't tested it with a large number of files, so I don't know how slow it will be):
1) Ask for Finder Items {Files} -- choose the text file
2) Combine Text FIles
3) Filter Paragraphs {Return paragraphs that are not empty}
4) Run AppleScript -- paste the following script:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters} -- build file paths from a list of names
set output to {}
set SkippedItems to {}
set TheFolder to (choose folder with prompt "Select the folder containing the files:") as text
repeat with AnItem in the input
try
set AnItem to (TheFolder & AnItem)
get AnItem as alias -- test
set the end of the output to the result
on error
set the end of SkippedItems to AnItem
end try
end repeat
if SkippedItems is not {} then
display alert "Error with AppleScript action" message ((count SkippedItems) as text) & " items were skipped (file not found)"
end if
return output
end run</pre>
5) Move Finder Items to Trash -
No dock icon for app made with Automator
No section on here for Automator?
I've made an app with Automator. It runs OK and has the same icon as Automator when saved to the Applications folder but when I run it, no icon appears in the dock. Is that normal or have I missed something? There's a rotating cog in the menu bar to show that the app is running (so I can stop it from there) and I can see its actions taking place but I was expecting a dock icon like all other apps.macfan7 wrote:
baltwo - I'd already left it on the dock but there's no "indicator light" to show it's running and no "quit" on the dock menu. It's no problem it's just not standard app behaviour.
Interesting, since AppleScript apps do show the indicator light. -
SQL query to find all suites that are associated with automation
I trying to incorporate CodeUI tests into a Release Mangement deployment template ... As a developer, I want to be able to specify a sub-tree of a test plan & only execute those test suites that are associated with automation. Is there a way to
extract all automated workitems and associated them with their respective test suites?
Any assistance would be greatly appreciated!John,
I've partially resolved the issue of executing a sub-set of suites with the following powershell implementation:
1. Extract "potential" suite paths from a XML configuration file:
<?xml version="1.0"?>
<Configurations>
<Properties>
<Property key="DEFAULT" value="SuitePaths" />
<Property key="DatabaseServer" value="MYDBSERVER" />
<Property key="DatabaseInstance" value="Default" />
<Property key="DatabaseName" value="TFS_DefaultCollection" />
<Property key="ConfigurationName" value="US - Windows 7 and IE 10" />
</Properties>
<Notifications>
<Notification key="0" value="[email protected]" />
</Notifications>
<SuitePaths>
<SuitePath key="0" value="MyProject\WebProduct\Student\Features\Login" />
<SuitePath key="1" value="MyProject\WebProduct\Student\Features\Logout" />
</SuitePaths>
<AreaPaths>
<AreaPath key="0" value="MyProject\WebProduct\Student\Features\Login" />
</AreaPaths>
</Configurations>
2. Extract record set of suites from TFS via SQL query:
# FUNCTION: Retrieve-SuitePaths
# Parameters:
# (1.) LogFile -- Name of log file (e.g., C:\Temp or C:\Temp\DEPLOY_DatabaseServer_WebCMS2_DF06_20131031.6.log)
# (2.) Connection -- Database connection
# (3.) Paths -- Hash table of suite paths
Function Retrieve-SuitePaths
param
[Parameter(Mandatory=$True)][String]$LogFile,
[Parameter(Mandatory=$True)]$Connection,
[Parameter(Mandatory=$True)]$Paths
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output "Retrieve suite(s): " | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
$SuitePaths = "("
$Counter = 0
foreach ($Key in $Paths.Keys)
if ($Counter -gt 0)
$SuitePaths = $SuitePaths + ", "
$SuitePaths = $SuitePaths + "'" + $Paths.Get_Item($Key) + "'"
$Counter += 1
$SuitePaths = $SuitePaths + ")"
# --DEBUG ONLY--> Write-Output "Paths: $SuitePaths" | Out-File -FilePath $LogFile -Append
$Command = New-Object System.Data.SqlClient.SqlCommand
$SQLStatement = "
WITH
cte_SuiteChildren
AS
-- Anchor definition to pull all certify modes
SELECT
S.[SuiteId],
S.[ProjectId],
PJ.ProjectName,
S.[PlanId],
P.[Name] AS PlanName,
S.[ParentSuiteId],
S.[SuitePath],
CONVERT(NVARCHAR(256), NULL) AS ParentTitle,
S.[Title],
0 AS RecurseLevel
FROM
[dbo].[tbl_Suite] AS S
INNER JOIN [dbo].[tbl_Plan] AS P ON S.PlanID = P.PlanID
INNER JOIN [dbo].[tbl_Project] AS PJ ON S.ProjectID = PJ.ProjectID
WHERE
S.ParentSuiteID = 0
UNION ALL
-- Recursive member to pull details of certify sessions
SELECT
S.[SuiteId],
S.[ProjectId],
PJ.ProjectName,
S.[PlanId],
P.[Name] AS PlanName,
S.[ParentSuiteId],
S.[SuitePath],
PS.[Title] AS ParentTitle,
S.[Title],
SC.[RecurseLevel] + 1 AS RecurseLevel
FROM
[dbo].[tbl_Suite] AS S
INNER JOIN cte_SuiteChildren AS SC on SC.SuiteID = S.ParentSuiteID
INNER JOIN [dbo].[tbl_Suite] AS PS ON SC.SuiteId = PS.SuiteId
INNER JOIN [dbo].[tbl_Plan] AS P ON S.PlanID = P.PlanID
INNER JOIN [dbo].[tbl_Project] AS PJ ON S.ProjectID = PJ.ProjectID
cte_SuiteLevel_0
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[ProjectName] + '\' + SC.[PlanName] AS Path,
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 0
cte_SuiteLevel_1
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 1
cte_SuiteLevel_2
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 2
cte_SuiteLevel_3
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 3
cte_SuiteLevel_4
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 4
cte_SuiteLevel_5
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 5
cte_SuiteLevel_6
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 6
cte_SuiteLevel_7
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 7
cte_SuiteLevel_8
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 8
cte_SuiteLevel_9
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 9
cte_SuiteLevel_10
AS
SELECT
SC.[ProjectId],
SC.[PlanId],
SC.[ParentSuiteId],
SC.[SuiteId],
SC.[ProjectName],
SC.[PlanName],
SC.[Title],
SC.[RecurseLevel]
FROM
cte_SuiteChildren AS SC
WHERE
SC.[RecurseLevel] = 10
cte_Suites
AS
SELECT
SL0.[ProjectId],
SL0.[PlanId],
CASE
WHEN SL2.ParentSuiteId IS NULL
THEN SL1.ParentSuiteId
ELSE CASE
WHEN SL3.ParentSuiteId IS NULL
THEN SL2.ParentSuiteId
ELSE CASE
WHEN SL4.ParentSuiteId IS NULL
THEN SL3.ParentSuiteId
ELSE CASE
WHEN SL5.ParentSuiteId IS NULL
THEN SL4.ParentSuiteId
ELSE CASE
WHEN SL6.ParentSuiteId IS NULL
THEN SL5.ParentSuiteId
ELSE CASE
WHEN SL7.ParentSuiteId IS NULL
THEN SL6.ParentSuiteId
ELSE CASE
WHEN SL8.ParentSuiteId IS NULL
THEN SL7.ParentSuiteId
ELSE CASE
WHEN SL9.ParentSuiteId IS NULL
THEN SL8.ParentSuiteId
ELSE CASE
WHEN SL10.ParentSuiteId IS NULL
THEN SL9.ParentSuiteId
ELSE SL10.ParentSuiteId
END
END
END
END
END
END
END
END
END AS [ParentSuiteId],
CASE
WHEN SL2.SuiteId IS NULL
THEN SL1.SuiteId
ELSE CASE
WHEN SL3.SuiteId IS NULL
THEN SL2.SuiteId
ELSE CASE
WHEN SL4.SuiteId IS NULL
THEN SL3.SuiteId
ELSE CASE
WHEN SL5.SuiteId IS NULL
THEN SL4.SuiteId
ELSE CASE
WHEN SL6.SuiteId IS NULL
THEN SL5.SuiteId
ELSE CASE
WHEN SL7.SuiteId IS NULL
THEN SL6.SuiteId
ELSE CASE
WHEN SL8.SuiteId IS NULL
THEN SL7.SuiteId
ELSE CASE
WHEN SL9.SuiteId IS NULL
THEN SL8.SuiteId
ELSE CASE
WHEN SL10.SuiteId IS NULL
THEN SL9.SuiteId
ELSE SL10.SuiteId
END
END
END
END
END
END
END
END
END AS [SuiteId],
SL0.ProjectName,
SL0.PlanName,
--SL0.Path,
--SL1.[Title],
CASE
WHEN SL2.Title IS NULL
THEN SL0.Path + '\' + SL1.Title
ELSE CASE
WHEN SL3.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title
ELSE CASE
WHEN SL4.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title
ELSE CASE
WHEN SL5.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title
ELSE CASE
WHEN SL6.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title
ELSE CASE
WHEN SL7.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title + '\' + SL6.Title
ELSE CASE
WHEN SL8.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title + '\' + SL6.Title + '\' + SL7.Title
ELSE CASE
WHEN SL9.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title + '\' + SL6.Title + '\' + SL7.Title + '\' + SL8.Title
ELSE CASE
WHEN SL10.Title IS NULL
THEN SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title + '\' + SL6.Title + '\' + SL7.Title + '\' + SL8.Title + '\' + SL9.Title
ELSE SL0.Path + '\' + SL1.Title + '\' + SL2.Title + '\' + SL3.Title + '\' + SL4.Title + '\' + SL5.Title + '\' + SL6.Title + '\' + SL7.Title + '\' + SL8.Title + '\' + SL9.Title + '\' + SL10.Title
END
END
END
END
END
END
END
END
END AS Path,
CASE
WHEN SL2.RecurseLevel IS NULL
THEN SL1.RecurseLevel
ELSE CASE
WHEN SL3.RecurseLevel IS NULL
THEN SL2.RecurseLevel
ELSE CASE
WHEN SL4.RecurseLevel IS NULL
THEN SL3.RecurseLevel
ELSE CASE
WHEN SL5.RecurseLevel IS NULL
THEN SL4.RecurseLevel
ELSE CASE
WHEN SL6.RecurseLevel IS NULL
THEN SL5.RecurseLevel
ELSE CASE
WHEN SL7.RecurseLevel IS NULL
THEN SL6.RecurseLevel
ELSE CASE
WHEN SL8.RecurseLevel IS NULL
THEN SL7.RecurseLevel
ELSE CASE
WHEN SL9.RecurseLevel IS NULL
THEN SL8.RecurseLevel
ELSE CASE
WHEN SL10.RecurseLevel IS NULL
THEN SL9.RecurseLevel
ELSE SL10.RecurseLevel
END
END
END
END
END
END
END
END
END AS RecurseLevel
FROM
cte_SuiteLevel_0 AS SL0
LEFT OUTER JOIN cte_SuiteLevel_1 AS SL1 ON SL1.ParentSuiteId = SL0.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_2 AS SL2 ON SL2.ParentSuiteId = SL1.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_3 AS SL3 ON SL3.ParentSuiteId = SL2.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_4 AS SL4 ON SL4.ParentSuiteId = SL3.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_5 AS SL5 ON SL5.ParentSuiteId = SL4.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_6 AS SL6 ON SL6.ParentSuiteId = SL5.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_7 AS SL7 ON SL7.ParentSuiteId = SL6.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_8 AS SL8 ON SL8.ParentSuiteId = SL7.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_9 AS SL9 ON SL9.ParentSuiteId = SL8.SuiteId
LEFT OUTER JOIN cte_SuiteLevel_10 AS SL10 ON SL10.ParentSuiteId = SL9.SuiteId
SELECT
SS.[ProjectId],
SS.[PlanId],
SS.[ParentSuiteId],
SS.[SuiteId],
SS.[ProjectName],
SS.[PlanName],
SS.[Path],
SS.[RecurseLevel]
FROM
SELECT DISTINCT
S.[ProjectId],
S.[PlanId],
S.[ParentSuiteId],
S.[SuiteId],
S.[ProjectName],
S.[PlanName],
S.[Path],
S.[RecurseLevel]
FROM
cte_Suites AS S
WHERE
S.[RecurseLevel] IS NOT NULL
AND S.[Path] IN $($SuitePaths)
) AS SS
ORDER BY
SS.[Path]
$Command.CommandText = $SQLStatement
$Command.Connection = $Connection
$Command.CommandTimeout = 240
$DataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$DataAdapter.SelectCommand = $Command
$DataSet = New-Object System.Data.DataSet
$DataAdapter.Fill($DataSet) | Out-Null
Write-Output "$SQLStatement" | Out-File -FilePath $LogFile -Append
# --DEBUG ONLY--> $DataSet.Tables[0]
return $DataSet
3. Execute every suite in the record set via TCM
$DataSet = ( Retrieve-SuitePaths -LogFile:$LogFile -Connection:$Connection -Path:$Paths)
# --DEBUG ONLY--> $DataSet.Tables[0].Rows.Count
# --DEBUG ONLY--> $DataSet.Tables[0]
# Determine whether or not any test suites were retrieved from TFS....
if ( $DataSet.Tables[0].Rows.Count -gt 0 )
$ListTestRunID = $null
$SumFailed = 0
$SumInconclusive = 0
foreach ($Row in $DataSet.Tables[0].Rows)
# Set project, plan & suite variables....
[Int16]$ProjectID = $Row.Item('ProjectId')
[Int16]$PlanID = $Row.Item('PlanId')
[Int16]$ParentSuiteID = $Row.Item('ParentSuiteId')
[Int16]$SuiteID = $Row.Item('SuiteId')
$ProjectName = $Row.Item('ProjectName')
$PlanName = $Row.Item('PlanName')
$Path = $Row.Item('Path')
$RecurseLevel = $Row.Item('RecurseLevel')
# Set local build path variable....
switch -wildcard ($Path)
"*WebCMS*\Administration\*"
$CUITBuildPath = $CUITPathUNC + '\WebCMS\Administration'
"*WebCMS*\Instructor\*"
$CUITBuildPath = $CUITPathUNC + '\WebCMS\Instructor'
"*WebCMS*\Student\*"
$CUITBuildPath = $CUITPathUNC + '\WebCMS\Student'
"*WebProduct*\Instructor\*"
$CUITBuildPath = $CUITPathUNC + '\WebProduct\Instructor'
"*WebProduct*\Student\*"
$CUITBuildPath = $CUITPathUNC + '\WebProduct\Student'
default
$CUITBuildPath = $CUITPathUNC
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output 'Test Suite:' | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output " ID:" | Out-File -FilePath $LogFile -Append
Write-Output " Project: $ProjectID" | Out-File -FilePath $LogFile -Append
Write-Output " Plan: $PlanID" | Out-File -FilePath $LogFile -Append
Write-Output " Parent Suite: $ParentSuiteID" | Out-File -FilePath $LogFile -Append
Write-Output " Suite: $SuiteID" | Out-File -FilePath $LogFile -Append
Write-Output " Config: $ConfigurationID" | Out-File -FilePath $LogFile -Append
Write-Output " Name:" | Out-File -FilePath $LogFile -Append
Write-Output " Project: $ProjectName" | Out-File -FilePath $LogFile -Append
Write-Output " Plan: $PlanName" | Out-File -FilePath $LogFile -Append
Write-Output " Config: $ConfigurationName" | Out-File -FilePath $LogFile -Append
Write-Output " Path:" | Out-File -FilePath $LogFile -Append
Write-Output " Suite: $Path" | Out-File -FilePath $LogFile -Append
Write-Output " Build: $CUITBuildPath" | Out-File -FilePath $LogFile -Append
# --DEBUG ONLY--> Write-Output " Recursion: $RecurseLevel" | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
# Set TCM arguements....
$ArguementPlanID = "/planid:$PlanID"
$ArguementTitle = "/title:$Title - $Path (SuiteID: $SuiteID)"
$ArguementSuiteID = "/suiteid:$SuiteID"
$ArguementConfigurationID = "/configid:$ConfigurationID"
$ArguementTFSCollection = "/collection:$TFSCollection"
$ArguementTeamProject = "/teamproject:$TFSTeamProject"
if(![string]::IsNullOrEmpty($CUITBuildPath))
$ArguementBuildDirectory = "/builddir:$CUITBuildPath"
$ArguementBuild = ""
$ArguementBuildDefinition = ""
else
$ArguementBuildDirectory = ""
$ArguementBuild = "/build:$TFSBuild"
$ArguementBuildDefinition = "/builddefinition:$BuildDefinition"
$ArguementTestEnvironment = "/testenvironment:$WebServer"
$ArguementSettingsName = ""
if(![string]::IsNullOrEmpty($SettingsName))
$ArguementSettingsName = "/settingsname:$SettingsName"
# Create test run....
Write-Host "$TCMEXE 'run' '/create' $ArguementTitle $ArguementPlanID $ArguementSuiteID $ArguementConfigurationID $ArguementTFSCollection $ArguementTeamProject $ArguementBuild $ArguementBuildDefinition $ArguementBuildDirectory $ArguementTestEnvironment $ArguementSettingsName"
Write-Output " $TCMEXE 'run' '/create' $ArguementTitle $ArguementPlanID $ArguementSuiteID $ArguementConfigurationID $ArguementTFSCollection $ArguementTeamProject $ArguementBuild $ArguementBuildDefinition $ArguementBuildDirectory $ArguementTestEnvironment $ArguementSettingsName" | Out-File -FilePath $LogFile -Append
try
$TestRunID = & $TCMEXE 'run' '/create' $ArguementTitle $ArguementPlanID $ArguementSuiteID $ArguementConfigurationID $ArguementTeamProject $ArguementTFSCollection $ArguementBuild $ArguementBuildDefinition $ArguementBuildDirectory $ArguementTestEnvironment $ArguementSettingsName
catch
$ExitMessage = $_Exception.Message
# --DEBUG ONLY--> Write-Output "TestRunID: $TestRunID" | Out-File -FilePath $LogFile -Append
if ($TestRunID -match '.+\:\s(?<TestRunID>\d+)\.')
# The test run ID is identified as a property in the match collection so we can access it directly by using the group name from the regular expression (i.e. TestRunID).
$TestRunID = $matches.TestRunID
$ArguementID = "/id:$TestRunID"
$TestRunResultsFile = $TempDirectory + "\TestRunResults$TestRunID.trx"
$ArguementQueryText = "/querytext:SELECT * FROM TestRun WHERE TestRunID=$TestRunID"
$ArguementResultsFile = "/resultsfile:""$TestRunResultsFile"""
Write-Host " Waiting for test run to complete ..."
Write-Host $TCMEXE 'run' '/list' $ArguementTeamProject $ArguementTFSCollection $ArguementQueryText
Write-Output " $TCMEXE 'run' '/list' $ArguementTeamProject $ArguementTFSCollection $ArguementQueryText" | Out-File -FilePath $LogFile -Append
$WaitingForTestRunCompletion = $true
$WaitCount= 0
while ($WaitingForTestRunCompletion)
$WaitCount = $WaitCount + 1
Write-Output " Waiting ($WaitCount)...." | Out-File -FilePath $LogFile -Append
Start-Sleep -s $TestRunWaitDelay
$TestRunStatus = & $TCMEXE 'run' '/list' $ArguementTeamProject $ArguementTFSCollection $ArguementQueryText
$TestRunStatus
if ($TestRunStatus.Count -lt 3 -or ($TestRunStatus.Count -gt 2 -and $TestRunStatus.GetValue(2) -match '.+(?<DateCompleted>\d+[/]\d+[/]\d+)'))
$WaitingForTestRunCompletion = $false
Write-Host "Evaluating test run $TestRunID results..."
# Take small pause(s) since the results might not be published yet....
Start-Sleep -s $TestRunWaitDelay
# Export results....
Write-Host $TCMEXE 'run' '/export' $ArguementID $ArguementTeamProject $ArguementTFSCollection $ArguementResultsFile
Write-Output " $TCMEXE 'run' '/export' $ArguementID $ArguementTeamProject $ArguementTFSCollection $ArguementResultsFile" | Out-File -FilePath $LogFile -Append
$WaitingForTestRunExport = $true
$WaitCount= 0
while ($WaitingForTestRunExport -and $WaitCount -lt 5)
$WaitCount = $WaitCount + 1
Write-Output " Waiting ($WaitCount)...." | Out-File -FilePath $LogFile -Append
$ExportResult = & $TCMEXE 'run' '/export' $ArguementID $ArguementResultsFile $ArguementTFSCollection $ArguementTeamProject
if ([System.IO.File]::Exists($TestRunResultsFile))
$WaitingForTestRunExport = $false
if ([System.IO.File]::Exists($TestRunResultsFile))
# Load the XML document contents.
[xml]$TestResultsXML = Get-Content "$TestRunResultsFile"
# Extract the results of the test run.
$TotalTests = $TestResultsXML.TestRun.ResultSummary.Counters.total
$PassedTests = $TestResultsXML.TestRun.ResultSummary.Counters.passed
$FailedTests = $TestResultsXML.TestRun.ResultSummary.Counters.failed
$InconclusiveTests = $TestResultsXML.TestRun.ResultSummary.Counters.inconclusive
# Output the results of the test run.
Write-Host "========== Test: $TotalTests tests ran, $PassedTests succeeded, $FailedTests failed, $InconclusiveTests inconclusive =========="
Write-Output "--------------------------------------------------------------------------------" | Out-File -FilePath $LogFile -Append
Write-Output "Summary:" | Out-File -FilePath $LogFile -Append
Write-Output "--------------------------------------------------------------------------------" | Out-File -FilePath $LogFile -Append
Write-Output " Total: $TotalTests" | Out-File -FilePath $LogFile -Append
Write-Output " Passed: $PassedTests" | Out-File -FilePath $LogFile -Append
Write-Output " Failed: $FailedTests" | Out-File -FilePath $LogFile -Append
Write-Output " Inconclusive: $InconclusiveTests" | Out-File -FilePath $LogFile -Append
$SumFailed += $FailedTests
$SumInconclusive += $InconclusiveTests
# Remove the test run results file.
[System.IO.File]::Delete($TestRunResultsFile) | Out-Null
# Add "current" TestRunID to the list of TestRunID(s)....
if ($ListTestRunID -ne $null)
$ListTestRunID = $ListTestRunID + ', '
$ListTestRunID = $ListTestRunID + $TestRunID
# Next test suite....
4. Extract record set of test runs from TFS via SQL query:
# FUNCTION: Retrieve-TestRuns
# Parameters:
# (1.) LogFile -- Name of log file (e.g., C:\Temp or C:\Temp\DEPLOY_DatabaseServer_WebCMS2_DF06_20131031.6.log)
# (2.) Connection -- Database connection
# (3.) ListTestRunID -- List of test run identifiers
Function Retrieve-TestRuns
param
[Parameter(Mandatory=$True)][String]$LogFile,
[Parameter(Mandatory=$True)]$Connection,
[Parameter(Mandatory=$True)][String]$ListTestRunID
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output "Retrieve test run(s): " | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
$TestRuns = '(' + $ListTestRunID + ')'
$Command = New-Object System.Data.SqlClient.SqlCommand
$SQLStatement = "
WITH
cte_State
AS
SELECT 0 AS [StateID], 'Unspecified' AS [StateName]
UNION ALL
SELECT 1 AS [OutcomeId], 'To Be Determined (1)' AS [StateName]
UNION ALL
SELECT 2 AS [StateID], 'In Progress' AS [StateName]
UNION ALL
SELECT 3 AS [StateID], 'Completed' AS [StateName]
UNION ALL
SELECT 4 AS [StateID], 'Aborted' AS [StateName]
UNION ALL
SELECT 5 AS [OutcomeId], 'To Be Determined (5)' AS [StateName]
UNION ALL
SELECT 6 AS [StateID], 'Needs Investigation' AS [StateName]
SELECT
TR.[ProjectId] AS [Project Id],
P.[ProjectName],
TR.[TestPlanId] AS [Plan Id],
TP.Name AS [TestPlanName],
TR.[TestRunId] AS [Run Id],
TR.[Title],
S.[StateID] AS [State Id],
S.[StateName] AS [State],
TR.[StartDate] AS [Date Started],
TR.[CompleteDate] AS [Date Completed],
DATEDIFF(SECOND, TR.[StartDate], TR.[CompleteDate]) AS Duration,
TR.[Type],
TR.[IsAutomated],
TR.[TotalTests] AS [Total],
TR.[PassedTests] AS [Passed],
TR.[IncompleteTests] AS [Incomplete],
TR.[UnanalyzedTests] AS [Unanalyzed],
TR.[NotApplicableTests] AS [Not Applicable]
FROM
[Tfs_DefaultCollection].[dbo].[tbl_TestRun] AS TR
INNER JOIN [Tfs_DefaultCollection].[dbo].[tbl_Project] AS P ON TR.ProjectId = P.ProjectId
INNER JOIN [Tfs_DefaultCollection].[dbo].[tbl_Plan] AS TP ON TR.TestPlanId = TP.PlanId
INNER JOIN cte_State AS S ON TR.[State] = S.[StateID]
WHERE
TR.TestRunId IN $($TestRuns)
ORDER BY
TR.[StartDate]
$Command.CommandText = $SQLStatement
$Command.Connection = $Connection
$Command.CommandTimeout = 30
$DataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$DataAdapter.SelectCommand = $Command
$DataSet = New-Object System.Data.DataSet
$DataAdapter.Fill($DataSet) | Out-Null
Write-Output "$SQLStatement" | Out-File -FilePath $LogFile -Append
# --DEBUG ONLY--> $DataSet.Tables[0]
return $DataSet
5. Extract record set of test results from TFS via SQL query:
# FUNCTION: Retrieve-TestRunResults
# Parameters:
# (1.) LogFile -- Name of log file (e.g., C:\Temp or C:\Temp\DEPLOY_DatabaseServer_WebCMS2_DF06_20131031.6.log)
# (2.) Connection -- Database connection
# (3.) ListTestRunID -- List of test run identifiers
Function Retrieve-TestRunResults
param
[Parameter(Mandatory=$True)][String]$LogFile,
[Parameter(Mandatory=$True)]$Connection,
[Parameter(Mandatory=$True)][String]$ListTestRunID
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output "Retrieve test result(s): " | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
$TestRuns = '(' + $ListTestRunID + ')'
$Command = New-Object System.Data.SqlClient.SqlCommand
$SQLStatement = "
WITH
cte_Outcome
AS
SELECT 0 AS [OutcomeId], 'To Be Determined (0)' AS [OutcomeName]
UNION ALL
SELECT 1 AS [OutcomeId], 'In Progress' AS [OutcomeName]
UNION ALL
SELECT 2 AS [OutcomeId], 'Passed' AS [OutcomeName]
UNION ALL
SELECT 3 AS [OutcomeId], 'Failed' AS [OutcomeName]
UNION ALL
SELECT 4 AS [OutcomeId], 'Inconclusive' AS [OutcomeName]
UNION ALL
SELECT 5 AS [OutcomeId], 'To Be Determined (5)' AS [OutcomeName]
UNION ALL
SELECT 6 AS [OutcomeId], 'Aborted' AS [OutcomeName]
UNION ALL
SELECT 7 AS [OutcomeId], 'Blocked' AS [OutcomeName]
UNION ALL
SELECT 8 AS [OutcomeId], 'Not Executed' AS [OutcomeName]
UNION ALL
SELECT 10 AS [OutcomeId], 'Error' AS [OutcomeName]
UNION ALL
SELECT 11 AS [OutcomeId], 'Not Applicable' AS [OutcomeName]
UNION ALL
SELECT 12 AS [OutcomeId], 'Paused' AS [OutcomeName]
UNION ALL
SELECT 13 AS [OutcomeId], 'To Be Determined (13)' AS [OutcomeName]
UNION ALL
SELECT 255 AS [OutcomeId], 'Never Run' AS [OutcomeName]
cte_State
AS
SELECT 0 AS [StateID], 'None' AS [StateName]
UNION ALL
SELECT 1 AS [StateID], 'Ready' AS [StateName]
UNION ALL
SELECT 2 AS [StateID], 'Completed' AS [StateName]
UNION ALL
SELECT 3 AS [StateID], 'Not Ready' AS [StateName]
UNION ALL
SELECT 4 AS [StateID], 'In Progress' AS [StateName]
UNION ALL
SELECT 5 AS [StateID], 'To Be Determined' AS [StateName]
SELECT DISTINCT
TR.[TestRunId] AS [Run Id],
TR.[TestCaseId] AS [Case Id],
O.[OutcomeID] AS [Outcome Id],
O.[OutcomeName] AS [Outcome],
S.[StateID] AS [State Id],
S.[StateName] AS [State],
TR.[TestCaseTitle] AS [Title],
TR.[AutomatedTestName] AS [Automation Method],
TR.[DateStarted] AS [Date Started],
TR.[DateCompleted] AS [Date Completed],
DATEDIFF(SECOND, TR.[DateStarted], TR.[DateCompleted]) AS Duration,
TR.[FailureType] AS [Failure Type],
TR.[ErrorMessage] AS [Error]
FROM
[Tfs_DefaultCollection].[dbo].[tbl_TestResult] AS TR
INNER JOIN cte_Outcome AS O ON TR.Outcome = O.OutcomeID
INNER JOIN cte_State AS S ON TR.State = S.StateID
WHERE
TR.TestRunId IN $($TestRuns)
ORDER BY
TR.[TestRunId],
O.[OutcomeName],
TR.[TestCaseTitle]
$Command.CommandText = $SQLStatement
$Command.Connection = $Connection
$Command.CommandTimeout = 30
$DataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$DataAdapter.SelectCommand = $Command
$DataSet = New-Object System.Data.DataSet
$DataAdapter.Fill($DataSet) | Out-Null
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output "SQL Statement: " | Out-File -FilePath $LogFile -Append
Write-Output '--------------------------------------------------------------------------------' | Out-File -FilePath $LogFile -Append
Write-Output "$SQLStatement" | Out-File -FilePath $LogFile -Append
# --DEBUG ONLY--> $DataSet.Tables[0]
return $DataSet
6. Email results to distribution list
Currently, I'm simplifying the extraction of suite path ... replacing hardcoded depth with STUFF() & XML PATH
Carl. -
How can I download images from website with Automator?
Hi!
I want to ask how can I download images from website with Automator like here http://www.youtube.com/watch?v=hQm7Xr9jY0w&t=85m15s (in 1:25:15).
I want to download these images to my downloads folder. Some things have changed and I can't find exact options as then. When I am trying to make it it shows "The action "Download URLs" was not supplied with the required data."
I am using 2012 late iMac with Mac OSX 9.2 (Mavericks).There are two apps that I know of - and I would also swear that they come from the same developer, although they've different names. Both have free trials and both cost $40 (but both do 'other' video conversion as well).
One is WonderShare - I bought this one and it works very well for downloading YouTube videos as well as converting just about any file format you can think of.
The other is iSkysoft Video Converter (just noticed that it's now $36).
I tried them both and finally decided on WonderShare. Give them both a trial run and decide if you like either one enough to buy it. I don't know of any 'free' software that will allow you to download and convert YouTube videos, but perhaps someone else will come along and know of something...
Good luck,
Clinton -
Hello all I am new to the apply community Im playing with automator in mountain lion I have figured out how to do some basic tasks but now I have run into a snag which I can't seem to find an awser for... I remember in the dos days for microsoft you could create batch files to rename a whole directory but there where certain things you could do like *.* to make it list everything etc... I want to rename files in my DLNA server DIRECTORY
so if my file name is
Criminal Minds 2.04 Psychodrama.avi
Criminal Minds 2.05 Aftermath.avi
I want automator to change it to
S02E04 - Psychodrama.avi
S02E05 - Aftermath.avi
I can get automator to delete the Criminal Minds etc. but I can't figure out how to get it to remember the numbers etc and change it to the new file
if anyone can help and maybe send me somewhere where I can get all the info on automator or maybe a script file would be a better soloution to begin with this but I don't know how to script either
thanks
Mike DennisonIf you have gone with A Better Finder Renamer, then that's cool.
I have rewritten and more thoroughly tested my Python script in Automator. If you use it as an Automator application on your Desktop, it will allow drag and drop folders or single files. It will now detect the folder and walk down through any sub-folders to ferret out your .avi files and (if they match the original filenaming format) rename the files in their present location, to your originally specified output format.
Note: The script will rename your original files to the specified new naming convention.
The last thing the script does is write a text logfile of processed files to your desktop. You can double-click this logfile and the OS X Console application will open and display it for you.
Open Automator.
Choose Application
Select Library > Run shell script
Drag this item to your right into the larger workflow window and release.
Choose Python from the selection list of script tools.
Choose Pass input: as arguments.
Remove all content from this window.
Copy the entire Python source from below, and paste into the open Automator window.
Click File > Save...
Select your Desktop as the save destination
Name the Automator application moviefix (arbitrary)
The automator application on your desktop is now enabled for drag and drop folders and files.
#!/usr/bin/env python
This program will convert files from one format to another.
From: Criminal Minds 2.01 The Fisher King (Part 2).avi
To: S02E01 - The Fisher King (Part 2).avi
Author: VikingOSX, Apple Support Community, 10/2013.
import sys
import os
import re
import time
#test = "Criminal Minds 2.01 The Fisher King (Part 2).avi"
LOGFILE = 'file-list.log'
DESKTOP = "~/Desktop"
# You can add to this list as comma-separated, single-quoted values.
valid_extension = ( '.avi' )
rename_list = []
def log_files(filelist):
Write processed files to logfile with time stamp.
cwdlog = os.path.join(os.path.expanduser(DESKTOP), LOGFILE)
with open(cwdlog, 'a+') as log:
# if new logfile, place header text in it
if os.stat(log.name).st_size == 0:
log.write("Processed Files\n")
log.flush()
for item in filelist:
log.write(logstamp(item))
def logstamp(thefile):
yyyy-mm-dd hh:mm:ss full path to filename.
stamp = time.strftime('%Y-%m-%d %X ') + thefile + '\n'
return stamp
def rename_file(path, thefile):
Renames files in their current directory location.
m = re.match(u'(\D*)(\d)\.(\d{2})(\s+\D*\S*)', thefile)
if m:
#show = m.group(1)
season = m.group(2)
episode = m.group(3)
title = m.group(4).lstrip()
newfile = "S" + season.zfill(2) + "E" + episode + " - " + title
rename_list.append(thefile)
os.rename(thefile, os.path.join(path, newfile))
return
def main():
for f in sys.argv[1:]:
# recursively process folders or n-tuple dropped files
if os.path.isdir(f):
for root, dirs, files in os.walk(os.path.abspath(f)):
for each in files:
if each.endswith(valid_extension):
rename_file(root, os.path.join(root, each))
else:
frp = os.path.realpath(f)
rename_file(frp)
if len(rename_list):
log_files(rename_list)
sys.exit(main())
Maybe you are looking for
-
Project Server 2010 Web services access with Client Certificate Authentication
We switched our SharePoint/Project Server 2010 farm to use client certificate authentication with Active Directory Federation Services (AD FS) 2.0, which is working without issue. We have some administrative Project Server Interface (PSI) web service
-
Please help me, I'd need to create XForms binding-exception with XHTML page
Hello, is anyone here who could help me? I've spent plenty of hours by searching the correct and suitable way for creating a binding exception in XForms, but I did not succeed... My situation is: I've got an XHTML page with XForms and XML (input) fil
-
Query regarding Error Messages
Dear All, Anyone please tell me how to display 'Error Messages in PCUI'. I tried using " Message MESAGEID type MESSAGETYPE number MESSAGENUMBER " but it did not work. Please provide some pointers on the above. Regards, Vijay
-
I have created a custom idoc and message type and a program that creates an idoc through fm is not getting executed by itself. My problem is that when I try to load the idoc from startrfc , idocs gets status 64 "IDoc ready to be transferred to appli
-
How do I install CS6 Photoshop free trial on my mac?
I downloaded it from the adobe site but cannot figure out how to install it.