Solved

get userid value


Badge

Hi, From a running workspace i would like to write the userid,starttime, endtime, and the filename of the workspace into a metadatafile. Starttime an Endtime is possible with datetimstamper but it is not accurate.

 

Does someone know the solution?

Kind regard Kees

 

 

icon

Best answer by david_r 12 August 2019, 11:59

View original

11 replies

Userlevel 4

What is it about the Endtime that isn't accurate?

Userlevel 5
Badge +25

You can't get the exact end time of the workspace while it is running, at least not with a DateTimeStamper. What you could try is using both a startup and a shutdown python script to get the start and end times although I would still argue that they might be slightly off from the exact times. I guess it all depends on how precise you want the results to be.

Alternatively you could parse the logfile afterwards using another workspace.

Badge

What is it about the Endtime that isn't accurate?

Hi david, thanks for your reaction. The writer comes after the datatimestamper so i don't have the shutdown time of the workspace.

Badge

You can't get the exact end time of the workspace while it is running, at least not with a DateTimeStamper. What you could try is using both a startup and a shutdown python script to get the start and end times although I would still argue that they might be slightly off from the exact times. I guess it all depends on how precise you want the results to be.

Alternatively you could parse the logfile afterwards using another workspace.

Thanks for your reaction. I'am not a python expert. Would you advise to use a pythonscript for all the items ( userid,starttime, endtime, and the filename)?

Userlevel 5
Badge +25

Thanks for your reaction. I'am not a python expert. Would you advise to use a pythonscript for all the items ( userid,starttime, endtime, and the filename)?

I'm not a Python expert myself either, but I'm sure somebody else here can give you some examples.

In short, yes, this could be a good way for at least the start and end times, although they would technically not be the exact times the workspace starts and stops, but as close to it as you can get within that workspace.

I'm not sure about the filename (but that can be hardcoded in to the logging) and userid though.

Userlevel 4

In this case, my recommendation would be to replace the regular writer with a FeatureWriter. The Summary port will not be triggered before everything as been written, making it fairly easy to generate and write a timestamp somewhere.

 

 

Badge

In this case, my recommendation would be to replace the regular writer with a FeatureWriter. The Summary port will not be triggered before everything as been written, making it fairly easy to generate and write a timestamp somewhere.

 

 

Thank you, i will try that. Do you also know a solution for getting the userid?

Userlevel 4

Thank you, i will try that. Do you also know a solution for getting the userid?

This is probably the easiest way of getting the username on a Windows machine:

The solution rest on some assumptions, so it should be tested in your network environment first.

Badge

This is probably the easiest way of getting the username on a Windows machine:

The solution rest on some assumptions, so it should be tested in your network environment first.

YES! thank you. Just wat i needed. This is a great transformer. Is there an overview with the possible variables. I can't find it in the knowledge center.

Userlevel 5
Badge +25

YES! thank you. Just wat i needed. This is a great transformer. Is there an overview with the possible variables. I can't find it in the knowledge center.

On Windows it would give you access to the environment variables, part of which can be user-defined. If you use the 'set' command, without parameters, on a command line it'll give you a list. On Mac it'd be the environment variables that you can see by using the 'env' command in Terminal. I don't have a Linux install handy to try but I would assume it'd be the same as on Mac.

Userlevel 4

On Windows it would give you access to the environment variables, part of which can be user-defined. If you use the 'set' command, without parameters, on a command line it'll give you a list. On Mac it'd be the environment variables that you can see by using the 'env' command in Terminal. I don't have a Linux install handy to try but I would assume it'd be the same as on Mac.

Yup, what he said. Just be aware that several or most of the environment variables may be client specific, so if you stray away from the (very few) slightly-standardized ones you'll need to test on all your clients to avoid surprise behavior from a system that depends on their presence.

Reply