• calculate diff between dates

    From =?UTF-8?B?16DXqteZINep15jXqNef?=@21:1/5 to All on Tue Jul 12 15:37:55 2022
    code:
    @app.route("/hosts/last_seen")
    def hst():
    #F1=falconpy
    #rr=struct_time()
    #rr.tm_hour=23
    #F= falconpy.APIHarness(client_id=client_id,client_secret=secret)
    #id_list = 'ID1,ID2,ID3' # Can also pass a list here: ['ID1', 'ID2', 'ID3']
    #response = F1.Hosts(client_id=client_id,client_secret=secret)
    d=datetime.datetime.fromtimestamp((datetime.datetime.now().utcnow(). timestamp()-86400*1.4)).isoformat()

    # F.command()
    # lasts=response.query_devices_by_filter(sort="hostname.asc")
    # return response.query_devices_by_filter(filter=f"hostname:{myid}*") #.QueryDevicesByFilter(filter=f"host:{myid}*")
    # )
    j=json2html.Json2Html
    #f.close()
    # hostname_result = hosts.query_devices_by_filter(filter=f""
    response = dict(a=falconpy.APIHarness(client_id=client_id,client_secret= secret).command("GetDeviceDetails", ids=list_of_aid))
    # t=response["b"]
    # t=falconpy.APIHarness(client_id=client_id,client_secret=secret).command("getHostGroups",
    ids=response["a"]["body"]["resources"][0]["groups"])

    #j=falconpy.APIHarness(client_id=client_id,client_secret=secret).command("query_hosts",filter='8d9285525ada4736bbd9368a2006f0ec')
    to=[]
    tc=list(range(len(response['a']['body']["resources"])))
    for i in response['a']['body']["resources"]:
    to.append((datetime.datetime.today())-datetime.datetime(). fromisoformat(str(i["last_seen"])))
    return dict(x=to,y=tc)




    I glad for any help

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael F. Stemper@21:1/5 to All on Tue Jul 12 08:22:41 2022
    On 12/07/2022 07.37, נתי שטרן wrote:

    [snip ugly code that I'm not going to try to understand]


    I glad for any help

    There wasn't any question in your post. However, I'm going to
    guess that there was the implied question of "How does one
    find the difference between two dates?"


    >>> import datetime
    >>> d1 = datetime.date(2022,1,1)
    >>> d2 = datetime.date(2022,7,12)
    >>> d2-d1
    datetime.timedelta(192)
    >>>


    --
    Michael F. Stemper
    If it isn't running programs and it isn't fusing atoms, it's just bending space.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From 2QdxY4RzWzUUiLuE@potatochowder.com@21:1/5 to nsh531@gmail.com on Tue Jul 12 08:11:25 2022
    On 2022-07-12 at 15:37:55 +0300,
    נתי שטרן <nsh531@gmail.com> wrote:

    I glad for any help

    http://www.sscce.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roel Schroeven@21:1/5 to All on Wed Jul 13 12:50:57 2022
    Op 12/07/2022 om 14:37 schreef נתי שטרן:
    I glad for any help
    http://www.catb.org/~esr/faqs/smart-questions.html

    --
    "Binnen een begrensde ruimte ligt een kritiek punt, waar voorbij de vrijheid afneemt naarmate het aantal individuen stijgt. Dit gaat evenzeer op voor mensen in de begrensde ruimte van een planetair ecosysteem, als voor de gasmoleculen in een hermetisch gesloten vat. Bij mensen is het niet de vraag hoeveel er maximaal in leven kunnen blijven in het systeem, maar wat voor soort bestaan mogelijk is voor diegenen die in leven blijven.
    -- Pardot Kynes, eerste planetoloog van Arrakis"
    -- Frank Herbert, Duin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)