~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to test/misc/make_date_test.py

  • Committer: dcoles
  • Date: 2008-05-09 07:43:37 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:753
Upload: Patch submitted by 'wagrant' to fix file upload of dos formated files 
and prevent corruption of upload files.

wagrant wrote:
> Last night I set up IVLE in my Gutsy schroot, and debugged it further.
> Looking deeper at the code, I noted it was a different error from the one I
> thought it was (an incorrect header, rather than lack of a Content-Type).
> This made the cause and fix obvious.
>
> http://qeuni.net/ivle_bug_1942845.diff fixes it for me in all the
> situations I can think of. It checks for the length of the header section
> obtained by splitting on a double LF then double CRLF, and takes the
> smaller one as the headers. In the old code, any output with a double CRLF
> in the body would have anything before the first CRLF treated as headers,
> which is wrong. Double LFs weren't affected because LFs are used by default
> to terminate the real headers.
>
> I apparently can't attach things (argh! I hate the SourceForge bug
> tracker).


Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Run in a user's jail to test the "short date format" displayed in the
 
3
# file browser's file table.
 
4
#
 
5
# Generates a bunch of files in the current directory and sets their date
 
6
# stamps to various dates in the past.
 
7
# The files are named after their date stamps relative to today.
 
8
#
 
9
# Author: Matt Giuca
 
10
# Date: 13/1/2008
 
11
 
 
12
import os
 
13
import time
 
14
 
 
15
seconds_per_day = 60*60*24
 
16
time_now = time.time()
 
17
 
 
18
if time.daylight:
 
19
    timezone_offset = time.altzone
 
20
else:
 
21
    timezone_offset = time.timezone
 
22
 
 
23
# Time at the beginning of today, local time
 
24
local_daystart \
 
25
    = time_now - int(time_now - timezone_offset) % seconds_per_day
 
26
 
 
27
def make_file_days_ago(days_ago):
 
28
    global time_now
 
29
    make_file(str(days_ago) + "days",
 
30
        time_now - seconds_per_day*days_ago)
 
31
def make_file(fname, timestamp):
 
32
    f = open(fname, 'w')
 
33
    f.close()
 
34
    os.utime(fname, (timestamp, timestamp))
 
35
 
 
36
make_file_days_ago(0)
 
37
make_file_days_ago(1)
 
38
make_file_days_ago(2)
 
39
make_file_days_ago(3)
 
40
make_file_days_ago(4)
 
41
make_file_days_ago(5)
 
42
make_file_days_ago(6)
 
43
make_file_days_ago(7)
 
44
make_file_days_ago(10)
 
45
make_file_days_ago(365)
 
46
 
 
47
# Now a boundary test - Make a file in the last second of Yesterday.
 
48
make_file("first_second_today", local_daystart)
 
49
make_file("last_second_yesterday", local_daystart-1)