InetGetSize bei Dateien auf FTP-Servern

  • Hallo an alle =)

    Folgendes:
    InetGetSize ist ja ganz gut und schön, jedoch hängt sich das bei bestimmten,
    größeren Dateien auf bestimmten FTP-Servern auf oder braucht einfach
    verdammt lange ;)

    Spoiler anzeigen
    [autoit]


    $get = ftp://xxx.xxx.xxx.xxx/xxx/xxx/xxx.zip ; halt ne Datei auf nem Server ;)
    $toping = StringReplace( $get, 'ftp://', '' )
    $toping2 = StringSplit( $toping, '/' )
    SetError( 0 )
    $ping = Ping( $toping2[1], 10000 )
    If $ping = 0 Then
    Exit
    Else
    If $ping < 500 Then
    ToolTip( 'Please wait, getting size... try 1/3', @DesktopWidth-200, @DesktopHeight-20 )
    $ftp_size = InetGetSize( $get )
    If $ftp_size = 0 Then
    ToolTip( '' )
    ToolTip( 'Getting size... try 2/3', @DesktopWidth-200, @DesktopHeight-20 )
    $ftp_size = InetGetSize( $get )
    If $ftp_size = 0 Then
    ToolTip( '' )
    ToolTip( 'Getting size... try 3/3', @DesktopWidth-200, @DesktopHeight-20 )
    $ftp_size = InetGetSize( $get )
    EndIf
    EndIf
    ToolTip( '' )
    EndIf
    EndIf

    [/autoit]

    Ich dachte vll gibts es ja eine Alternative zu InetGetSize
    oder die Möglichkeit ein solches Abzubrechen...

    schonmal Danke =)

    Noels

    There are only 10 types of people in the world:
    Those who understand binary - and those who don't.

  • Hallo.

    Also wenn Du nur die Datei runter laden möchtest, dann kann ich Dir empfehlen, die folgendes anzusehen:

    Spoiler anzeigen
    [autoit]

    InetGet("http://www.autoit.de/dokumentation/functions/InetGet.htm", "InetGet.htm", 1)

    [/autoit] [autoit][/autoit] [autoit]

    While @InetGetActive
    TrayTip("Downloading", "Bytes = " & @InetGetBytesRead, 10, 16)
    Sleep(250)
    Wend

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, "Bytes read", @InetGetBytesRead)

    [/autoit]

    Mit diesem beispiel ziehst du die [InetGet.html] down. Wenn Dir das reicht, dann sollte Dein Problem gelößt sein. Einfach sonst melden udn wir suchen weiter nach Hilfe.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Ich möchte aber auch wissen wie weit
    der gerade ist ;) Also im Bezug auf die Gesamtgröße... ^^

    There are only 10 types of people in the world:
    Those who understand binary - and those who don't.

  • Hallo.

    Also wenn ich das beim Downloaden wissen möchte, dann mache ich den Download so:

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    Global Const $ES_AUTOVSCROLL = 64
    Global Const $ES_AUTOHSCROLL = 128
    Global Const $ES_WANTRETURN = 4096
    Global Const $WS_POPUPWINDOW = 0x80880000
    Global Const $WS_EX_CLIENTEDGE = 0x00000200
    Global Const $WS_EX_TOOLWINDOW = 0x00000080
    Global Const $WS_GROUP = 0x00020000
    Global Const $ES_READONLY = 0x0800
    Global Const $GUI_SHOW = 16
    Global Const $GUI_HIDE = 32
    Global Const $GUI_DISABLE = 128
    Global Const $PBS_SMOOTH = 1
    Global Const $PBS_VERTICAL = 4
    Global Const $SS_LEFT = 0x0000
    Global Const $SS_RIGHT = 0x0002
    Global Const $SS_CENTER = 0x01
    Global Const $WS_EX_OVERLAPPEDWINDOW = 0x00000300
    Global Const $WS_EX_TRANSPARENT = 0x00000020
    Global Const $SS_NOTIFY = 0x0100
    Global $file_size_bytes = 1
    Global $file_size = 1

    $Datei1 = "sav32sfx.exe"
    $Quelle1 = "http://www.sophos.com/tools/sav32sfx.exe"
    $Ziel1 = @ScriptDir & $Datei1
    ;
    $Datei2 = "web_ides.exe"
    $Quelle2 = "http://www.sophos.com/downloads/ide/web_ides.exe"
    $Ziel2 = @ScriptDir & $Datei2
    ;
    $Form1 = GUICreate("", 400, 350, -1, -1,$WS_POPUPWINDOW,$WS_EX_TOOLWINDOW)
    GUISetBkColor(0x004A6F)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Group1 = GUICtrlCreateGroup("Sophus-Download", 8, 8, 382, 134)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Progress1 = GUICtrlCreateProgress(24, 102, 300, 17, $PBS_SMOOTH)
    GUICtrlSetBkColor(-1, 0x000080)
    ;GUICtrlSetColor(-1,0xff0000)
    $Label1 = GUICtrlCreateLabel("QUELLE : " & $Quelle1,24,30,358,17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("ZIEL : " & $Ziel1,24,50,358,17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label3 = GUICtrlCreateLabel("",24,70,358,17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label4 = GUICtrlCreateLabel("",325,102,50,17, $SS_RIGHT)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Group2 = GUICtrlCreateGroup("", 8, 142, 382, 100)
    GUISetState(@SW_SHOW)
    ;--> 1. Datei download
    ;_download_progress($Datei1,$Quelle1)
    ;Sleep(1000)
    ;--> 2. Datei download
    ;$Label1 = GUICtrlCreateLabel("QUELLE : " & $Quelle2,24,30,358,17)
    ;GUICtrlSetColor(-1, 0xFFFFFF)
    ;$Label2 = GUICtrlCreateLabel("ZIEL : " & $Ziel2,24,50,358,17)
    ;GUICtrlSetColor(-1, 0xFFFFFF)
    _download_progress($Datei2,$Quelle2)
    Sleep(1000)
    ;
    Func _download_progress($filename, $fileurl)
    $file_size_bytes = InetGetSize($fileurl)
    $file_size = $file_size_bytes
    InetGet($fileurl, $filename, 1, 1)
    While @InetGetActive
    Sleep(50)
    $iniDown = @InetGetBytesRead
    $xx = porcentDown($iniDown, $file_size)
    GUICtrlSetColor($Progress1,0xdbdbdb)
    $msg_downloading = "Download: " & $iniDown & " / " & $file_size
    $dif_bytes = @InetGetBytesRead - $iniDown
    GUICtrlSetData ($Progress1,$xx)
    GUICtrlCreatePic("A1.bmp", 24+50*int($xx/20), 170, 50, 38, BitOR($SS_NOTIFY,$WS_GROUP))
    GUICtrlSetData($Label3,$msg_downloading)
    GUICtrlSetData($Label4,StringFormat("%3.2f",$xx) & " %")
    Wend
    EndFunc
    ;
    Func porcentDown($iniDown, $file_size)
    Return Round( (($iniDown/$file_size_bytes)*100) , 2)
    EndFunc
    ;
    Func _Filesize($iValue, $sFormat, $iDecimal = 10)
    Local $sReturn, $iB, $iKB, $iMB, $iGB
    If $iValue = 0 Then
    Return "0 Bytes"
    EndIf
    If Not StringIsDigit(Round($iValue)) Or Not StringIsDigit(Round($iDecimal)) Then
    SetError(1)
    Return 0
    EndIf
    ; Conversion Chart
    $iB = $iValue
    $iKB = ($iB / 1024)
    $iMB = ($iKB / 1024)
    $iGB = ($iMB / 1024)
    Select
    Case $sFormat = "0" ; Auto Select Format Display Type
    If $iValue >= 1073741824 Then
    $iValue = Round($iGB,$iDecimal) & " GB"
    ElseIf $iValue >= 1048576 Then
    $iValue = Round($iMB,$iDecimal) & " MB"
    ElseIf $iValue >= 1024 Then
    $iValue = Round($iKB,$iDecimal) & " KB"
    ElseIf $iValue >= 1 Then
    $iValue = Round($iB,$iDecimal) & " B "
    EndIf
    Case $sFormat = "1"
    $iValue = Round($iGB,$iDecimal) & " GB"
    Case $sFormat = "2"
    $iValue = Round($iMB,$iDecimal) & " MB"
    Case $sFormat = "3"
    $iValue = Round($iKB,$iDecimal) & " KB"
    Case $sFormat = "4"
    $iValue = Round($iB,$iDecimal) & " B "
    EndSelect
    Return $iValue
    EndFunc ;==>_Filesize
    ;--EOF

    [/autoit]

    Script ist NICHT von mir !!!

    Vllt. ist es ja das, was Du suchst oder es hilft Dir weiter bei dem was Du möchtest.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Oh man ^^
    es ist ja nicht das Problem, dass ich nicht weiß, wie ich das anzeigen soll...
    Es ist halt so, dass das InetGetSize manchmal versagt ! =(

    Und in meinem Script geht es halt NUR um das Downloaden von
    Dateien.

    Es gibt im Inet so ne FTP-Suchmaschine, da findet man so ziemlich
    alles.. ^^ Und die will ich halt in ein Programm umsetzen.
    Und wenn da ein InetGetSize mein Prog zum Absturzt bringt ist das
    verdammt Sche*** ;)
    Hab extra vorher schon ne Pingabfrage gesetzt..
    Aber trotzdem.. :P
    ..
    Und es gibt keine Alternative ? Und man kann InetGetSize auch kein Zeitlimit geben ? ...

    noels

    There are only 10 types of people in the world:
    Those who understand binary - and those who don't.

  • So..
    Mit Unterstützung von GTA hab ichs doch geschafft,
    ich dachte vll könnte es euch unter Umständen auch interessieren ;)

    Mir ging es ja darum, dass mein Script nicht an einem InetGetSize hängen bleibt;
    hab es jetzt mit einem 2.Script gelöst:

    Main:

    Spoiler anzeigen
    [autoit]


    Func _InetGetSize( $l )
    FileDelete( @MyDocumentsDir & '\temp.dat' )
    FileDelete( @MyDocumentsDir & '\temp2.dat' )
    FileWrite( @MyDocumentsDir & '\temp.dat', $l )
    Run( @MyDocumentsDir & '\getsize.exe' )
    $init = TimerInit()
    Do
    $size = FileRead( @MyDocumentsDir & '\temp2.dat' )
    Until @error <> 1 Or TimerDiff( $init ) > 30000

    [/autoit] [autoit][/autoit] [autoit]

    If $size = '' Then
    MsgBox( 0, 'size=""', @error )
    ProcessClose( 'getsize.exe' )
    Return 0
    Else
    Return $size
    EndIf
    EndFunc

    [/autoit]

    GetSize.exe:

    [autoit]


    #NoTrayIcon
    $link = FileRead( @MyDocumentsDir & '\temp.dat' )
    $s = InetGetSize( $link )
    FileWrite( @MyDocumentsDir & '\temp2.dat', $s )

    [/autoit]

    Trotzdem danke ;)

    noels =)

    There are only 10 types of people in the world:
    Those who understand binary - and those who don't.

  • Alina hast du eine Idee wie man in deinem Script noch mitgeben kann wo
    die Daten gespeichert werden sollen?

  • Zitat

    Original von janos
    Alina hast du eine Idee wie man in deinem Script noch mitgeben kann wo
    die Daten gespeichert werden sollen?

    hi janos,
    die daten werden gemäss der variablen $ziel1 (zeile 26) und $ziel2 (zeile 30) gespeichert. also dort, wo das programm liegt.

    allerdings lädt das programm durch die auskommentierten zeilen nur das file web_ides.exe runter, obwohl mit der progressbar die datei sav32sfx.exe angezeigt wird. aber das lässt sich ja schnell ändern.

    gruss exberliner

  • Zitat

    Original von ExBerliner

    hi janos,
    die daten werden gemäss der variablen $ziel1 (zeile 26) und $ziel2 (zeile 30) gespeichert. also dort, wo das programm liegt.

    allerdings lädt das programm durch die auskommentierten zeilen nur das file web_ides.exe runter, obwohl mit der progressbar die datei sav32sfx.exe angezeigt wird. aber das lässt sich ja schnell ändern.

    gruss exberliner

    so gehts :)

    38 $Ziel1 = @TempDir & "\" & $Datei1
    82 InetGet($fileurl, $Ziel1, 1, 1)