#StackBounty: #python-3.x #scheduled-tasks #python-asyncio Python 3.9 – Scheduling periodic calls of async function with different para…

Bounty: 50

How to in python 3.9 implement the functionality of calling the async functions with different parameters, by scheduled periods? The functionality should be working on any OS (Linux, Windows, Mac)

I have a function fetchOHLCV which downloads market data from exchanges. The function has two input parameters – pair, timeframe.
Depending on the pair and timeframe values the function download data from exchanges and stores them in DB.

The goal – call this function with different periods with different parameters.

1) fetchOHLCV(pair ='EUR/USD', timeframe="1m") - each minute
2) fetchOHLCV(pair ='EUR/USD', timeframe="1h") - each new hour.
3) fetchOHLCV(pair ='EUR/USD', timeframe="1d") - each new day 
4) fetchOHLCV(pair ='EUR/USD', timeframe="1w") - each new week

At this moment I don’t have experience working with scheduling in python and I don’t know which libraries will optimal for my task and I’m interested in the best practices of implementing similar tasks.


Get this bounty!!!

#StackBounty: #windows-10 #scheduled-tasks SOLVED: task scheduler not triggered on event

Bounty: 100

so I have made myself a little script and a scheduled task to be triggered when I connect to VPN. First it seemed like it works, but later it stopped and I wonder why!
enter image description here
as you can see the events are logged but the task is not triggered.

task trigger definition:
enter image description here

XML export of the task in case anyone likes it more then the picture:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-08-19T15:43:28.3039862</Date>
    <Author>AzureADVitezslavZurek</Author>
    <URI>VPNconnect-changemapping</URI>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="System"&gt;&lt;Select Path="System"&gt;*[System[Provider[@Name='rasman'] and EventID=20267]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-12-1-3505324469-1115195118-3040547712-752804357</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-file C:batchVPNconnect-changeMapping.ps1</Arguments>
    </Exec>
  </Actions>
</Task>

The other task on eventid 20268 also does not work.
I can run them both manually though.

EDIT: I have no idea what happened but something got unstuck and it works now! Tasks are triggered. I didn’t event do reboot.


Get this bounty!!!

#StackBounty: #windows-10 #scheduled-tasks #windows-task-scheduler Scheduled task execute at wrong times on Windows 10

Bounty: 100

On Windows 10 I created a scheduled task to make a snapshot of C: each hour from 8:00 AM to 5:00 PM.
Works fine as long as the computer is running or stopped (not sleeping).

Problem : if the computer fall asleep during 8 AM – 5 PM, the scheduled task is fired when the computer wake up.
For example the computer fall asleep at 4:45 PM. It wake up at 9:15 PM, a snapshot is done, which is not desired.

How can I prevent the scheduled task to do its job outside the desired hours?

The task is exported there:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2019-01-01T00:00:00.00</Date>
    <Author>Author</Author>
    <URI>VSS</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <Repetition>
        <Interval>PT1H</Interval>
        <Duration>PT8H</Duration>
        <StopAtDurationEnd>false</StopAtDurationEnd>
      </Repetition>
      <StartBoundary>2019-01-01T09:00:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByWeek>
        <DaysOfWeek>
          <Monday />
          <Tuesday />
          <Wednesday />
          <Thursday />
          <Friday />
        </DaysOfWeek>
        <WeeksInterval>1</WeeksInterval>
      </ScheduleByWeek>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT10M</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:WindowsSystem32wbemWMIC.exe</Command>
      <Arguments>shadowcopy call create Volume=C:</Arguments>
    </Exec>
  </Actions>
</Task>


Get this bounty!!!

#StackBounty: #python-2.x #geospatial #scheduled-tasks Reload polyline midpoints into parallel tables

Bounty: 50

I have an Oracle GIS database that has spatial tables. The records in the spatial tables have a geometry column that contains polylines.

I’ve written a Python 2.7.16 script that calculates the midpoint of the polylines and inserts the midpoint information into parallel tables. The script will be run as part of a nightly scheduled job on a server.

Note: I use the short form FC in the code, which stands for Feature Class. A
feature class is an ESRI GIS term that can be thought of as a table with a geometry column.


What the code does:

  1. Loops through a list. Each row in the list has an input FC, a target FC, and an ID field.
  2. For each row in the list:
    • Truncate the target FC
    • Populate the target FC with midpoints from the input FC

So yeah, I’m new to Python. How can the code be improved?

import arcpy
conn = "Database Connections\<YOUR CONNECTION.sde>\"

#This script only works for polyline feature classes (not polygons or points).
#Caution! The target FCs will get truncated! All records in the target FCs will be deleted.

#       INPUT FC               TARGET FC                     ID FIELD (for both the input FC and the target FC)    
lstFC = [
        ["<OWNER>.<SIDEWALK>", "<OWNER>.S_SIDEWLK_MIDPOINT", "SDW_ID"   ],
        ["<OWNER>.<SEWER>"   , "<OWNER>.S_SEWER_MIDPOINT"  , "SEWER_ID" ],
        ["<OWNER>.<ROAD>"    , "<OWNER>.S_ROAD_MIDPOINT"   , "ROAD_ID"  ],
        ]

def ReloadMidpoints():
    for fc in lstFC:
        inputFC  = conn + (fc)[0]
        targetFC = conn + (fc)[1]
        idField  = (fc)[2]

        arcpy.TruncateTable_management(targetFC)
        print "<" + targetFC + "> has been truncated."

        with arcpy.da.SearchCursor(inputFC, ['SHAPE@', idField]) as s_rows:
            with arcpy.da.InsertCursor(targetFC, ['SHAPE@', idField, "MIDPOINT_X","MIDPOINT_Y"]) as i_rows:
                for row in s_rows:
                    Midpoint = row[0].positionAlongLine(0.50,True).firstPoint
                    rowVals = [(Midpoint.X,Midpoint.Y),s_rows[1],Midpoint.X,Midpoint.Y]
                    i_rows.insertRow(rowVals)

        print "<" + targetFC + "> has been reloaded with midpoints that were generated from <" + (inputFC) + ">."
        print ""

ReloadMidpoints()
print "Complete."


Get this bounty!!!

#StackBounty: #windows #windows-10 #scheduled-tasks #windows-task-scheduler #task-scheduler task-scheduler: How can all users view/edit…

Bounty: 50

I want all (or selected) users/admins to view/edit/run the same taks. It seems that each user/admin only sees his own tasks and not the others users’.

This is quite confusing for me since on Linux a user with the right can view/change all cron jobs. So the jobs are tied to the maschine and not to the user on the maschine.


Get this bounty!!!