Skip to main content
Solved

get userid value


Forum|alt.badge.img

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

 

 

Best answer by david_r

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.

 

 

View original
Did this help you find an answer to your question?

11 replies

david_r
Celebrity
  • August 12, 2019

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


redgeographics
Celebrity
Forum|alt.badge.img+49

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.


Forum|alt.badge.img
  • Author
  • August 12, 2019
david_r wrote:

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.


Forum|alt.badge.img
  • Author
  • August 12, 2019
redgeographics wrote:

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)?


redgeographics
Celebrity
Forum|alt.badge.img+49
kees_v wrote:

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.


david_r
Celebrity
  • Best Answer
  • August 12, 2019

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.

 

 


Forum|alt.badge.img
  • Author
  • August 12, 2019
david_r wrote:

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?


david_r
Celebrity
  • August 12, 2019
kees_v wrote:

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.


Forum|alt.badge.img
  • Author
  • August 13, 2019
david_r wrote:

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.


redgeographics
Celebrity
Forum|alt.badge.img+49
kees_v wrote:

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.


david_r
Celebrity
  • August 14, 2019
redgeographics wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings