text:
.class public Lorg/holoeverywhere/app/Dialog;
.super Landroid/app/Dialog;
.source "Dialog.java"

# interfaces
.implements Lcom/actionbarsherlock/internal/view/menu/ContextMenuDecorView$ContextMenuListenersProvider;
.implements Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;

# instance fields
.field private mContextMenuListeners:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Landroid/view/View;",
            "Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;",
            ">;"
        }
    .end annotation
.end field

.field private mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 44
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0}, Lorg/holoeverywhere/app/Dialog;-><init>(Landroid/content/Context;I)V

    .line 45
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;I)V
    .locals 2
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "theme"    # I

    .prologue
    .line 55
    invoke-static {p1, p2}, Lorg/holoeverywhere/app/Dialog;->checkTheme(Landroid/content/Context;I)I

    move-result v0

    const/4 v1, -0x1

    invoke-direct {p0, p1, v0, v1}, Lorg/holoeverywhere/app/Dialog;-><init>(Landroid/content/Context;II)V

    .line 56
    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lorg/holoeverywhere/app/Dialog;->setCancelable(Z)V

    .line 57
    return-void
.end method

.method private constructor <init>(Landroid/content/Context;II)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "theme"    # I
    .param p3, "fallback"    # I

    .prologue
    .line 60
    new-instance v0, Lorg/holoeverywhere/app/ContextThemeWrapperPlus;

    invoke-direct {v0, p1, p2}, Lorg/holoeverywhere/app/ContextThemeWrapperPlus;-><init>(Landroid/content/Context;I)V

    invoke-direct {p0, v0, p2}, Landroid/app/Dialog;-><init>(Landroid/content/Context;I)V

    .line 61
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;ZLandroid/content/DialogInterface$OnCancelListener;)V
    .locals 0
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "cancelable"    # Z
    .param p3, "cancelListener"    # Landroid/content/DialogInterface$OnCancelListener;

    .prologue
    .line 49
    invoke-direct {p0, p1}, Lorg/holoeverywhere/app/Dialog;-><init>(Landroid/content/Context;)V

    .line 50
    invoke-virtual {p0, p2}, Lorg/holoeverywhere/app/Dialog;->setCancelable(Z)V

    .line 51
    invoke-virtual {p0, p3}, Lorg/holoeverywhere/app/Dialog;->setOnCancelListener(Landroid/content/DialogInterface$OnCancelListener;)V

    .line 52
    return-void
.end method

.method private static final checkTheme(Landroid/content/Context;I)I
    .locals 4
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "theme"    # I

    .prologue
    .line 29
    const/high16 v1, 0x1000000

    if-lt p1, v1, :cond_0

    .line 37
    .end local p1    # "theme":I
    :goto_0
    return p1

    .line 32
    .restart local p1    # "theme":I
    :cond_0
    new-instance v0, Landroid/util/TypedValue;

    invoke-direct {v0}, Landroid/util/TypedValue;-><init>()V

    .line 33
    .local v0, "value":Landroid/util/TypedValue;
    invoke-virtual {p0}, Landroid/content/Context;->getTheme()Landroid/content/res/Resources$Theme;

    move-result-object v1

    sget v2, Lorg/holoeverywhere/R$attr;->dialogTheme:I

    const/4 v3, 0x1

    invoke-virtual {v1, v2, v0, v3}, Landroid/content/res/Resources$Theme;->resolveAttribute(ILandroid/util/TypedValue;Z)Z

    .line 34
    iget v1, v0, Landroid/util/TypedValue;->resourceId:I

    if-lez v1, :cond_1

    .line 35
    iget p1, v0, Landroid/util/TypedValue;->resourceId:I

    goto :goto_0

    .line 37
    :cond_1
    sget p1, Lorg/holoeverywhere/R$style;->Holo_Theme_Dialog:I

    goto :goto_0
.end method

.method private requestDecorView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;I)Z
    .locals 4
    .param p1, "view"    # Landroid/view/View;
    .param p2, "params"    # Landroid/view/ViewGroup$LayoutParams;
    .param p3, "layoutRes"    # I

    .prologue
    const/4 v0, 0x1

    const/4 v3, -0x1

    .line 146
    iget-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    if-eqz v1, :cond_0

    .line 159
    :goto_0
    return v0

    .line 149
    :cond_0
    new-instance v1, Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-direct {v1, v2}, Lorg/holoeverywhere/internal/WindowDecorView;-><init>(Landroid/content/Context;)V

    iput-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    .line 150
    iget-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    const v2, 0x1020002

    invoke-virtual {v1, v2}, Lorg/holoeverywhere/internal/WindowDecorView;->setId(I)V

    .line 151
    iget-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v1, p0}, Lorg/holoeverywhere/internal/WindowDecorView;->setProvider(Lcom/actionbarsherlock/internal/view/menu/ContextMenuDecorView$ContextMenuListenersProvider;)V

    .line 152
    if-eqz p1, :cond_2

    .line 153
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v0, p1, p2}, Lorg/holoeverywhere/internal/WindowDecorView;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 157
    :cond_1
    :goto_1
    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getWindow()Landroid/view/Window;

    move-result-object v0

    iget-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    new-instance v2, Landroid/view/ViewGroup$LayoutParams;

    invoke-direct {v2, v3, v3}, Landroid/view/ViewGroup$LayoutParams;-><init>(II)V

    invoke-virtual {v0, v1, v2}, Landroid/view/Window;->setContentView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 159
    const/4 v0, 0x0

    goto :goto_0

    .line 154
    :cond_2
    if-lez p3, :cond_1

    .line 155
    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getLayoutInflater()Lorg/holoeverywhere/LayoutInflater;

    move-result-object v1

    iget-object v2, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v1, p3, v2, v0}, Lorg/holoeverywhere/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    goto :goto_1
.end method

# virtual methods
.method public addContentView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V
    .locals 1
    .param p1, "view"    # Landroid/view/View;
    .param p2, "params"    # Landroid/view/ViewGroup$LayoutParams;

    .prologue
    .line 65
    const/4 v0, -0x1

    invoke-direct {p0, p1, p2, v0}, Lorg/holoeverywhere/app/Dialog;->requestDecorView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;I)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 66
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v0, p1, p2}, Lorg/holoeverywhere/internal/WindowDecorView;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 68
    :cond_0
    return-void
.end method

.method public getContextMenuListener(Landroid/view/View;)Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;
    .locals 1
    .param p1, "view"    # Landroid/view/View;

    .prologue
    .line 72
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    if-nez v0, :cond_0

    .line 73
    const/4 v0, 0x0

    .line 75
    :goto_0
    return-object v0

    :cond_0
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    invoke-interface {v0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;

    goto :goto_0
.end method

.method public bridge synthetic getLayoutInflater()Landroid/view/LayoutInflater;
    .locals 1

    .prologue
    .line 26
    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getLayoutInflater()Lorg/holoeverywhere/LayoutInflater;

    move-result-object v0

    return-object v0
.end method

.method public getLayoutInflater()Lorg/holoeverywhere/LayoutInflater;
    .locals 1

    .prologue
    .line 80
    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getContext()Landroid/content/Context;

    move-result-object v0

    invoke-static {v0}, Lorg/holoeverywhere/LayoutInflater;->from(Landroid/content/Context;)Lorg/holoeverywhere/LayoutInflater;

    move-result-object v0

    return-object v0
.end method

.method public final onContextItemSelected(Landroid/view/MenuItem;)Z
    .locals 1
    .param p1, "item"    # Landroid/view/MenuItem;

    .prologue
    .line 85
    new-instance v0, Lcom/actionbarsherlock/internal/view/menu/ContextMenuItemWrapper;

    invoke-direct {v0, p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuItemWrapper;-><init>(Landroid/view/MenuItem;)V

    invoke-virtual {p0, v0}, Lorg/holoeverywhere/app/Dialog;->onContextItemSelected(Lcom/actionbarsherlock/view/MenuItem;)Z

    move-result v0

    return v0
.end method

.method public onContextItemSelected(Lcom/actionbarsherlock/view/MenuItem;)Z
    .locals 1
    .param p1, "item"    # Lcom/actionbarsherlock/view/MenuItem;

    .prologue
    .line 90
    instance-of v0, p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuItemWrapper;

    if-eqz v0, :cond_0

    .line 91
    check-cast p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuItemWrapper;

    .end local p1    # "item":Lcom/actionbarsherlock/view/MenuItem;
    invoke-virtual {p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuItemWrapper;->unwrap()Landroid/view/MenuItem;

    move-result-object v0

    invoke-super {p0, v0}, Landroid/app/Dialog;->onContextItemSelected(Landroid/view/MenuItem;)Z

    move-result v0

    .line 94
    :goto_0
    return v0

    .restart local p1    # "item":Lcom/actionbarsherlock/view/MenuItem;
    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public final onContextMenuClosed(Landroid/view/Menu;)V
    .locals 1
    .param p1, "menu"    # Landroid/view/Menu;

    .prologue
    .line 106
    instance-of v0, p1, Landroid/view/ContextMenu;

    if-eqz v0, :cond_0

    .line 107
    new-instance v0, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    check-cast p1, Landroid/view/ContextMenu;

    .end local p1    # "menu":Landroid/view/Menu;
    invoke-direct {v0, p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;-><init>(Landroid/view/ContextMenu;)V

    invoke-virtual {p0, v0}, Lorg/holoeverywhere/app/Dialog;->onContextMenuClosed(Lcom/actionbarsherlock/view/ContextMenu;)V

    .line 112
    :goto_0
    return-void

    .line 110
    .restart local p1    # "menu":Landroid/view/Menu;
    :cond_0
    invoke-super {p0, p1}, Landroid/app/Dialog;->onContextMenuClosed(Landroid/view/Menu;)V

    goto :goto_0
.end method

.method public onContextMenuClosed(Lcom/actionbarsherlock/view/ContextMenu;)V
    .locals 1
    .param p1, "menu"    # Lcom/actionbarsherlock/view/ContextMenu;

    .prologue
    .line 99
    instance-of v0, p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    if-eqz v0, :cond_0

    .line 100
    check-cast p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    .end local p1    # "menu":Lcom/actionbarsherlock/view/ContextMenu;
    invoke-virtual {p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;->unwrap()Landroid/view/ContextMenu;

    move-result-object v0

    invoke-super {p0, v0}, Landroid/app/Dialog;->onContextMenuClosed(Landroid/view/Menu;)V

    .line 102
    :cond_0
    return-void
.end method

.method public final onCreateContextMenu(Landroid/view/ContextMenu;Landroid/view/View;Landroid/view/ContextMenu$ContextMenuInfo;)V
    .locals 1
    .param p1, "menu"    # Landroid/view/ContextMenu;
    .param p2, "view"    # Landroid/view/View;
    .param p3, "menuInfo"    # Landroid/view/ContextMenu$ContextMenuInfo;

    .prologue
    .line 117
    new-instance v0, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    invoke-direct {v0, p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;-><init>(Landroid/view/ContextMenu;)V

    invoke-virtual {p0, v0, p2, p3}, Lorg/holoeverywhere/app/Dialog;->onCreateContextMenu(Lcom/actionbarsherlock/view/ContextMenu;Landroid/view/View;Landroid/view/ContextMenu$ContextMenuInfo;)V

    .line 118
    return-void
.end method

.method public onCreateContextMenu(Lcom/actionbarsherlock/view/ContextMenu;Landroid/view/View;Landroid/view/ContextMenu$ContextMenuInfo;)V
    .locals 1
    .param p1, "menu"    # Lcom/actionbarsherlock/view/ContextMenu;
    .param p2, "view"    # Landroid/view/View;
    .param p3, "menuInfo"    # Landroid/view/ContextMenu$ContextMenuInfo;

    .prologue
    .line 123
    instance-of v0, p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    if-eqz v0, :cond_0

    .line 124
    check-cast p1, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;

    .end local p1    # "menu":Lcom/actionbarsherlock/view/ContextMenu;
    invoke-virtual {p1}, Lcom/actionbarsherlock/internal/view/menu/ContextMenuWrapper;->unwrap()Landroid/view/ContextMenu;

    move-result-object v0

    invoke-super {p0, v0, p2, p3}, Landroid/app/Dialog;->onCreateContextMenu(Landroid/view/ContextMenu;Landroid/view/View;Landroid/view/ContextMenu$ContextMenuInfo;)V

    .line 127
    :cond_0
    return-void
.end method

.method public registerForContextMenu(Landroid/view/View;)V
    .locals 1
    .param p1, "view"    # Landroid/view/View;

    .prologue
    .line 131
    sget-boolean v0, Lorg/holoeverywhere/HoloEverywhere;->WRAP_TO_NATIVE_CONTEXT_MENU:Z

    if-eqz v0, :cond_0

    .line 132
    invoke-super {p0, p1}, Landroid/app/Dialog;->registerForContextMenu(Landroid/view/View;)V

    .line 136
    :goto_0
    return-void

    .line 134
    :cond_0
    invoke-virtual {p0, p1, p0}, Lorg/holoeverywhere/app/Dialog;->registerForContextMenu(Landroid/view/View;Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;)V

    goto :goto_0
.end method

.method public registerForContextMenu(Landroid/view/View;Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;)V
    .locals 1
    .param p1, "view"    # Landroid/view/View;
    .param p2, "listener"    # Lcom/actionbarsherlock/internal/view/menu/ContextMenuListener;

    .prologue
    .line 139
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    if-nez v0, :cond_0

    .line 140
    new-instance v0, Lorg/holoeverywhere/util/WeaklyMap;

    invoke-direct {v0}, Lorg/holoeverywhere/util/WeaklyMap;-><init>()V

    iput-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    .line 142
    :cond_0
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    invoke-interface {v0, p1, p2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 143
    return-void
.end method

.method public setCancelable(Z)V
    .locals 0
    .param p1, "flag"    # Z

    .prologue
    .line 164
    invoke-super {p0, p1}, Landroid/app/Dialog;->setCancelable(Z)V

    .line 165
    invoke-virtual {p0, p1}, Lorg/holoeverywhere/app/Dialog;->setCanceledOnTouchOutside(Z)V

    .line 166
    return-void
.end method

.method public setContentView(I)V
    .locals 3
    .param p1, "layoutResID"    # I

    .prologue
    const/4 v0, 0x0

    .line 170
    invoke-direct {p0, v0, v0, p1}, Lorg/holoeverywhere/app/Dialog;->requestDecorView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;I)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 171
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v0}, Lorg/holoeverywhere/internal/WindowDecorView;->removeAllViewsInLayout()V

    .line 172
    invoke-virtual {p0}, Lorg/holoeverywhere/app/Dialog;->getLayoutInflater()Lorg/holoeverywhere/LayoutInflater;

    move-result-object v0

    iget-object v1, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    const/4 v2, 0x1

    invoke-virtual {v0, p1, v1, v2}, Lorg/holoeverywhere/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    .line 174
    :cond_0
    return-void
.end method

.method public setContentView(Landroid/view/View;)V
    .locals 2
    .param p1, "view"    # Landroid/view/View;

    .prologue
    const/4 v1, -0x1

    .line 178
    new-instance v0, Landroid/view/ViewGroup$LayoutParams;

    invoke-direct {v0, v1, v1}, Landroid/view/ViewGroup$LayoutParams;-><init>(II)V

    invoke-virtual {p0, p1, v0}, Lorg/holoeverywhere/app/Dialog;->setContentView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 179
    return-void
.end method

.method public setContentView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V
    .locals 1
    .param p1, "view"    # Landroid/view/View;
    .param p2, "params"    # Landroid/view/ViewGroup$LayoutParams;

    .prologue
    .line 183
    const/4 v0, -0x1

    invoke-direct {p0, p1, p2, v0}, Lorg/holoeverywhere/app/Dialog;->requestDecorView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;I)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 184
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v0}, Lorg/holoeverywhere/internal/WindowDecorView;->removeAllViewsInLayout()V

    .line 185
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mDecorView:Lorg/holoeverywhere/internal/WindowDecorView;

    invoke-virtual {v0, p1, p2}, Lorg/holoeverywhere/internal/WindowDecorView;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 187
    :cond_0
    return-void
.end method

.method public unregisterForContextMenu(Landroid/view/View;)V
    .locals 1
    .param p1, "view"    # Landroid/view/View;

    .prologue
    .line 191
    sget-boolean v0, Lorg/holoeverywhere/HoloEverywhere;->WRAP_TO_NATIVE_CONTEXT_MENU:Z

    if-eqz v0, :cond_1

    .line 192
    invoke-super {p0, p1}, Landroid/app/Dialog;->unregisterForContextMenu(Landroid/view/View;)V

    .line 198
    :cond_0
    :goto_0
    return-void

    .line 194
    :cond_1
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    if-eqz v0, :cond_0

    .line 195
    iget-object v0, p0, Lorg/holoeverywhere/app/Dialog;->mContextMenuListeners:Ljava/util/Map;

    invoke-interface {v0, p1}, Ljava/util/Map;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_0
.end method

redpajama_set_name: RedPajamaGithub


text:
Christine Lahti Cast As Gloria Steinem In Emily Mann's Off Broadway Play
By Greg Evans
Greg Evans
Associate Editor/Broadway Critic
@GregEvans5
More Stories By Greg
White House Ambitions For Inaugural Poet? Amanda Gorman Tells James Corden, "Heck Yeah, Planning On It"
Watch: Lady Gaga, Jennifer Lopez & Garth Brooks Sing In Biden-Harris Administration
President Donald Trump To America: "Have A Good Life, We'll See You Soon"
Peter Lee Ash/AP
Christine Lahti has been cast as feminist icon Gloria Steinem in the previously announced Off Broadway production of Having Our Say playwright Emily Mann's new play Gloria: A Life.
The play, to be directed by Diane Paulus (Waitress) and produced by Tony-winning producer Daryl Roth (Kinky Boots) at the Daryl Roth Theatre on Union Square in Manhattan, will begin previews Tuesday, October 2 and open Thursday, October 18.
"Gloria Steinem helped me find feminism, which has been my life jacket, a way to navigate through a world that doesn't treat girls and women like full human beings," Lahti said upon her casting. "For over forty years, she has worked tirelessly to enrich, empower and save women's lives. To be able to play her and tell her remarkable story is one of the greatest thrills and honors of my life, not to mention my career."
Said Steinem: "I'm honored to be represented by Christine, and I know I will learn from her insights, too."
The casting was announced by producer Roth. The production team has previously announced an all-female creative and producing team.
Lahti's stage credits include God of Carnage, The Heidi Chronicles, Present Laughter, Suzan-Lori Parks' Fucking A and Three Hotels, among many others. Films include Swing Shift, Running on Empty, Leaving Normal, and …and Justice for All, while TV appearances include Chicago Hope, Grace and Frankie, Hawaii Five-O and Law & Order SVU.
Mann's play is described by the production as weaving "together personal and history-changing moments of the past fifty years, from consciousness among a few women, to the majority tipping point of national and global consciousness that we are now witnessing. Starting with Gloria's early adventures as a rare female reporter, the revelations of the play include stories of the people who inspired her and led her to inspire others."
Act One will focus on Steinem's personal life and activism, while Act Two will take the form of a "Talking Circle" in which the audience will be invited to carry the themes of the play "into a conversation of their own."
Explained Steinem, "What makes me feel enthusiastic about this whole idea is that after Act One about my life, the audience will take over and become a talking circle with a life of its own. During many years of traveling and organizing, I've come to have great faith in the magic of people talking together after a shared experience. Computers may give us information, but only being together with all five senses creates empathy and action."
Roth says, "We feel it's incredibly important to be telling this story at this moment in time, Gloria's life and all she has accomplished brings us hope, reminding us how far we've come, and inspiring a new generation to go further."
Lahti is repped by ICM Partners and managed by Echo Lake.
In an unrelated Steinem bio-project, director Julie Taymor is planning the biopic My Life on the Road, written by Sarah Ruhl and starring Julianne Moore as Steinem.
This article was printed from	https://deadline.com/2018/06/christine-lahti-cast-gloria-steinem-emily-mann-off-broadway-play-gloria-a-life-1202418404/

redpajama_set_name: RedPajamaCommonCrawl


text:
Polio Home > OPV
How Effective Is It?
OPV is highly effective in producing immunity to poliovirus. A single dose of OPV produces immunity in approximately 50 percent of recipients. Three doses of OPV will produce immunity to all three poliovirus types in more than 95 percent of recipients. As with other live-virus vaccines, immunity from OPV is probably life-long.
Comparing OPV to Inactivated Polio Vaccine
There are two general polio vaccine types. One type is inactivated polio vaccine (IPV), meaning that the vaccine contains no live poliovirus. The other type is live OPV, which contains live but weakened poliovirus.
Until recently, OPV was recommended for most children in the United States. Because OPV helped rid the United States of polio (and because it is less expensive than the newer inactivated polio vaccine), it is still used in many parts of the world.
Both vaccines give immunity to polio, but OPV is better at keeping the disease from spreading to other people. However, for a few people (about one in 2.4 million), OPV actually causes polio (known as vaccine-associated paralytic polio). Since the risk of getting polio in the United States is now extremely low, experts believe that using OPV is no longer worth the slight risk, except in limited circumstances, which your doctor can describe. The polio shot (inactivated polio vaccine) does not cause polio.
(Click Polio Vaccine to learn more about the inactivated polio vaccine.)
Oral Polio Vaccine: Vaccine-Associated Paralytic Poliomyelitis
Vaccine-associated paralytic poliomyelitis is a rare adverse reaction that can come from the oral polio vaccine. It is caused by vaccine-derived poliovirus. One case of vaccine-associated paralytic poliomyelitis occurred for every 2 to 3 million doses of OPV administered. This resulted in 8 to 10 cases of vaccine-associated paralytic poliomyelitis each year in the United States.
From 1980 through 1999, vaccine-associated paralytic poliomyelitis accounted for 95 percent of all cases of paralytic poliomyelitis reported in the United States.
(Click Vaccine-Associated Paralytic Poliomyelitis to learn more about this rare but serious reaction to oral polio vaccine.)
Last reviewed by: Kristi Monson, PharmD;
IPOL [package insert]. Swiftwater, PA: Sanofi Pasteur, Inc.;2005 December.
Kinrix [package insert]. Research Triangle Park, NC: GlaxoSmithKline Biologicals;2009 March.
Pediarix [package insert]. Research Triangle Park, NC: GlaxoSmithKline Biologicals;2009 July.
Pentacel [package insert]. Swiftwater, PA: Sanofi Pasteur, Inc.;2008 June.
Centers for Disease Control and Prevention (CDC). Vaccine information statement: polio vaccine (1/31/00). CDC Web site. Available at: http://www.cdc.gov/vaccines/pubs/vis/downloads/vis-IPV.pdf. Accessed August 25, 2009.
Polio Vaccine Side Effects
Vaccine-Derived Poliovirus
Vaccine-Associated Paralytic Poliomyelitis
Polio Vaccine Precautions


text:
A Club They Won't Join
By Josh Kurtz
Jim Pederson is a realist.
The chairman of the Arizona Democratic Party believes that Sen. John McCain (R-Ariz.) will be almost impossible to beat in a general election next year. And there's some question whether Democrats even want to knock off McCain, who regularly gives GOP leaders fits.
Pederson is so close to the maverick Republican that the two met in Washington last month to discuss strategy for defeating an upcoming ballot measure that would overturn Arizona's public financing system for state elections. Coincidentally or not, Rep. Jeff Flake — who is contemplating challenging McCain in a GOP primary next year — is leading the fight to kill public financing.
It's Pederson's hunch that Flake or another formidable Republican will take on McCain in the GOP primary — and possibly even defeat him — with the help of the conservative anti-tax group the Club for Growth. If that happens, Pederson believes that the Democrats can be competitive in the Senate race.
"Arizona is not the old conservative backwater that a lot of people [in Washington, D.C.] think it is," he said.
Hence the dilemma for the Democrats. Do they merely put up a sacrificial lamb under the assumption that McCain will be the Republican nominee? Or do they recruit a top-tier candidate with the hope that McCain stumbles in the GOP primary?
This type of dilemma could turn into a rare electoral opportunity for the Democrats in what is shaping up to be a difficult election for them. And it's being served up to them, at least in part, by the Club for Growth — one of the key organizations encouraging Republican-on-Republican battles.
At this early stage of the 2004 cycle, there are at least two Senate races where aggressive conservative challengers could take on unorthodox Republican incumbents in GOP primaries — in states where the Democrats might otherwise not be competitive. In addition to Arizona, where the club is urging Flake to enter the race, Democrats are watching Pennsylvania, where three-term Rep. Pat Toomey (R), a Club for Growth favorite, has announced that he will challenge moderate Sen. Arlen Specter (R).
Similarly, there are perhaps half a dozen House districts on the Eastern seaboard where moderate Republican incumbents may face primary challenges from conservatives, giving the Democrats a chance to compete for seats that were once thought to be unwinnable.
"I think a primary challenge to any incumbent mitigates the advantages of incumbency," said Brad Woodhouse, communications director at the Democratic Senatorial Campaign Committee.
Woodhouse said the presence of conservative challengers to GOP incumbents has become a selling point for DSCC recruiters to use on potential Democratic candidates. "It does go into the decision making for potential recruits," he said.
But if any top-tier Democrats are interested in running for Senate in Arizona or Pennsylvania, they have not come forward yet.
Pederson, a wealthy businessman, is the Democrat most likely to run if it appears that McCain will lose. Former state Attorney General Grant Woods, a Republican, is considering switching parties to make a statewide race.
In Pennsylvania, where Democrats are emboldened by Gov. Ed Rendell's (D) hefty victory last year, no big-league Democrat has admitted to even thinking about running for Senate. Still, national Democrats have their eyes on a few up and comers, including Pittsburgh Mayor Tom Murphy and Allegheny County District Attorney Stephen Zappala Jr.
Complicating matters for Democrats is uncertainty over how active Rendell will be in recruiting and supporting a Senate candidate over Specter. Specter was once Rendell's boss in the Philadelphia D.A.'s office, and the two are close.
In both Pennsylvania and Arizona, Democrats will have to calculate how strong the challenges to the Republican incumbents are going to be, and decide whether they are poised to take advantage. The filing deadline in Arizona is June 9, 2004; in Pennsylvania, it's Feb. 17, 2004.
Ron Talley, director of the Republican Main Street Partnership, a group that supports moderate Republicans, blasts Club for Growth and other conservative organizations that take on GOP incumbents, arguing that divisive primary challenges weaken the party.
"In Pennsylvania, the Democrats are salivating over the prospect of a [GOP] primary," he said. "We consider the primary a total waste of Republican dollars that could be well used to defeat Democrats."
But Stephen Moore, Club for Growth's president, defended his group's support of Toomey and other conservative Republican challengers, and said any damage to the GOP from internecine warfare would be minimal. Moore predicted that whoever wins the Republican primary in Pennsylvania — Toomey or Specter — will win the general election.
"Toomey is just such a star in the House," he said. "Whenever one of our stars is running for higher office, then we have to be with them, win or lose."
Toomey disputed the argument that he is too conservative to win statewide in Pennsylvania. He noted that his Allentown-based House district leans Democratic, and that Sen. Rick Santorum (R-Pa.) is a conservative who has won two statewide elections.
"I wouldn't be entering this race if I wasn't convinced I can win," he said.
Moore said that while Club for Growth is encouraging Flake to challenge McCain in Arizona, any decision is probably months away.
On the House side, the club has not selected any races to become involved with yet. But it is easy to see where conservative challengers could emerge.
In New York's 24th district, Cayuga County Legislator David Walrath (R), who ran a seat-of-the-pants challenge to moderate Rep. Sherwood Boehlert (R) last year, is gearing up to try again. He is starting much earlier and is sure to be better funded. And in Maryland's 1st district, where Club for Growth got behind conservative lawyer David Fischer in his unsuccessful primary challenge to Rep. Wayne Gilchrest (R) a year ago, state Sen. Richard Colburn (R) has a fundraiser scheduled for Friday and is expected to announce his plans to run against Gilchrest.
Both districts lean Republican, and in each case the moderate Republican incumbent seems to fit the district well. But both districts are competitive in presidential elections — especially Boehlert's — and a conservative Congressional nominee could have trouble winning if the Democrats put up a strong candidate.
Similarly, moderate Republican Reps. Jeb Bradley (N.H.), Mike Castle (Del.), Amo Houghton (N.Y.), Nancy Johnson (Conn.) and Rob Simmons (Conn.) could face conservative challenges next year, and most are in competitive districts.
Moore said his organization might get behind challengers in two or three of these districts. "I don't know how it's going to pan out," he said.


SEAHUNT is comprised of Los Angeles-based touring, studio and recording musicians who perform multiple musical styles. From classic rock and modern pop hits to classic and contemporary jazz. We are flexible enough to read your crowd and change styles when needed to keep your dance floor filled.
SEAHUNT is comprised of Los Angeles-based touring, studio and recording musicians who perform multiple musical styles. From classic rock and modern pop hits to classic and contemporary jazz. From Sinatra to Bruno Mars based on your vision, needs and entertainment goals. We are flexible enough to read your crowd and change styles when needed to keep your dance floor filled.


Opening in limited release today: The indie offerings this week include a dash of heavy metal, a financial-politics documentary, and cannibals!
Metallica: Through The Never: Despite the presence and full participation of Metallica, this is not a documentary, but rather a narrative film about a roadie (Dane DeHaan) for the metal legends, who goes on an errand for the band and encounters … a riot? Monsters? The apocalypse? So we're looking at a 3D part-concert movie, part-action blockbuster. It might end up selling tickets just on the curiosity factor alone.
Muscle Shoals: Sound City was a hit documentary in the first half of 2013, so why wouldn't the marketplace be able to bear another doc about a classic recording studio, this time the titular Muscle Shoals in Alabama, which produced such hits as "Brown Sugar" and "I'll Take You There."
We Are What We Are: This here is an English-language remake of the 2010 Mexican horror film of the same name. The original made a name for itself on the festival circuit as an uncommonly affecting horror film. It may be about cannibals, but it's also about … family?
Inequality for All: Former Labor Secretary Robert Reich finds himself the subject of Jacob Kornbluth's documentary about the country's economic problems and ever-widening class gap. Fun stuff? Likely not. But very possibly necessary nonetheless.


text:
El Estadio Luis Álamos Luque, ubicado en la ciudad de Chañaral (Chile), cuenta con una capacidad de 3000 espectadores. Su propietario es el gobierno regional de Atacama, en mancomunidad con la Ilustre Municipalidad de Chañaral. El recinto tiene una potente iluminación y cancha de pasto sintético, inaugurada en 2007.

El estadio lleva el nombre del destacado exfutbolista y entrenador chileno Luis "El Zorro" Álamos, nacido en Chañaral, que dirigió a Universidad de Chile en sus títulos de 1959, 1962, 1964 y 1965, gestando el equipo conocido como Ballet Azul; a Colo-Colo, llevándolo al subcampeonato de Copa Libertadores de América en 1973, y a la selección de fútbol de Chile en los campeonatos mundiales de Inglaterra 1966 y Alemania 1974.

Iluminación
Las luminarias fueros inauguradas en el año 2003, en ceremonia que contó con la presencia de Héctor Volta Rojas, alcalde de la ciudad, y Clara Osandon Arredondo, gobernadora provincial de Chañaral. La medida provocó el repudio de los vecinos de las calles colindantes, pues alegan no poder dormir con tanta luz.

Pasto
Tras años de estudios y con la noticia de que el Salvador cierra, la Municipalidad de Chañaral decidió instalar una capa de pasto sintético en la superficie del recinto deportivo ante la posibilidad de que Cobresal juegue como local en Chañaral, y de que la ciudad busque entrar con un equipo en la competencia de la Tercera división chilena. La obra estaba lista en abril de 2007, con un costo cercano a los 300 millones de pesos En su inauguración estuvieron presentes Viviana Ireland, Intendenta de Atacama y Héctor Volta, Alcalde de Chañaral.

Posiblemente se amplíen las graderías, que en estos momentos son de madera.

Véase también
Luis Álamos

Referencias

Luis Alamos Luque, Estadio
Chañaral

redpajama_set_name: RedPajamaWikipedia


text:
import unittest
import os
import mock
from gzip import GzipFile
from shutil import rmtree
import cPickle as pickle
import time
import tempfile
from contextlib import contextmanager, closing
from errno import ENOENT, ENOTEMPTY, ENOTDIR

from eventlet.green import subprocess
from eventlet import Timeout, tpool

from test.unit import debug_logger, patch_policies
from swift.common import utils
from swift.common.utils import hash_path, mkdirs, normalize_timestamp, \
    storage_directory
from swift.common import ring
from swift.obj import diskfile, replicator as object_replicator
from swift.common.storage_policy import StoragePolicy, POLICIES

def _ips():
    return ['127.0.0.0']
object_replicator.whataremyips = _ips

def mock_http_connect(status):

    class FakeConn(object):

        def __init__(self, status, *args, **kwargs):
            self.status = status
            self.reason = 'Fake'
            self.host = args[0]
            self.port = args[1]
            self.method = args[4]
            self.path = args[5]
            self.with_exc = False
            self.headers = kwargs.get('headers', {})

        def getresponse(self):
            if self.with_exc:
                raise Exception('test')
            return self

        def getheader(self, header):
            return self.headers[header]

        def read(self, amt=None):
            return pickle.dumps({})

        def close(self):
            return
    return lambda *args, **kwargs: FakeConn(status, *args, **kwargs)

process_errors = []

class MockProcess(object):
    ret_code = None
    ret_log = None
    check_args = None

    class Stream(object):

        def read(self):
            return MockProcess.ret_log.next()

    def __init__(self, *args, **kwargs):
        targs = MockProcess.check_args.next()
        for targ in targs:
            # Allow more than 2 candidate targs
            # (e.g. a case that either node is fine when nodes shuffled)
            if isinstance(targ, tuple):
                allowed = False
                for target in targ:
                    if target in args[0]:
                        allowed = True
                if not allowed:
                    process_errors.append("Invalid: %s not in %s" % (targ,
                                                                     args))
            else:
                if targ not in args[0]:
                    process_errors.append("Invalid: %s not in %s" % (targ,
                                                                     args))
        self.stdout = self.Stream()

    def wait(self):
        return self.ret_code.next()

@contextmanager
def _mock_process(ret):
    orig_process = subprocess.Popen
    MockProcess.ret_code = (i[0] for i in ret)
    MockProcess.ret_log = (i[1] for i in ret)
    MockProcess.check_args = (i[2] for i in ret)
    object_replicator.subprocess.Popen = MockProcess
    yield
    object_replicator.subprocess.Popen = orig_process

def _create_test_rings(path, devs=None):
    testgz = os.path.join(path, 'object.ring.gz')
    intended_replica2part2dev_id = [
        [0, 1, 2, 3, 4, 5, 6],
        [1, 2, 3, 0, 5, 6, 4],
        [2, 3, 0, 1, 6, 4, 5],
    ]
    intended_devs = devs or [
        {'id': 0, 'device': 'sda', 'zone': 0,
         'region': 1, 'ip': '127.0.0.0', 'port': 6000},
        {'id': 1, 'device': 'sda', 'zone': 1,
         'region': 2, 'ip': '127.0.0.1', 'port': 6000},
        {'id': 2, 'device': 'sda', 'zone': 2,
         'region': 1, 'ip': '127.0.0.2', 'port': 6000},
        {'id': 3, 'device': 'sda', 'zone': 4,
         'region': 2, 'ip': '127.0.0.3', 'port': 6000},
        {'id': 4, 'device': 'sda', 'zone': 5,
         'region': 1, 'ip': '127.0.0.4', 'port': 6000},
        {'id': 5, 'device': 'sda', 'zone': 6,
         'region': 2, 'ip': 'fe80::202:b3ff:fe1e:8329', 'port': 6000},
        {'id': 6, 'device': 'sda', 'zone': 7, 'region': 1,
         'ip': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'port': 6000},
    ]
    intended_part_shift = 30
    with closing(GzipFile(testgz, 'wb')) as f:
        pickle.dump(
            ring.RingData(intended_replica2part2dev_id,
                          intended_devs, intended_part_shift),
            f)

    testgz = os.path.join(path, 'object-1.ring.gz')
    with closing(GzipFile(testgz, 'wb')) as f:
        pickle.dump(
            ring.RingData(intended_replica2part2dev_id,
                          intended_devs, intended_part_shift),
            f)
    for policy in POLICIES:
        policy.object_ring = None  # force reload
    return

@patch_policies([StoragePolicy(0, 'zero', False),
                StoragePolicy(1, 'one', True)])
class TestObjectReplicator(unittest.TestCase):

    def setUp(self):
        utils.HASH_PATH_SUFFIX = 'endcap'
        utils.HASH_PATH_PREFIX = ''
        # Setup a test ring (stolen from common/test_ring.py)
        self.testdir = tempfile.mkdtemp()
        self.devices = os.path.join(self.testdir, 'node')
        rmtree(self.testdir, ignore_errors=1)
        os.mkdir(self.testdir)
        os.mkdir(self.devices)
        os.mkdir(os.path.join(self.devices, 'sda'))
        self.objects = os.path.join(self.devices, 'sda',
                                    diskfile.get_data_dir(POLICIES[0]))
        self.objects_1 = os.path.join(self.devices, 'sda',
                                      diskfile.get_data_dir(POLICIES[1]))
        os.mkdir(self.objects)
        os.mkdir(self.objects_1)
        self.parts = {}
        self.parts_1 = {}
        for part in ['0', '1', '2', '3']:
            self.parts[part] = os.path.join(self.objects, part)
            os.mkdir(self.parts[part])
            self.parts_1[part] = os.path.join(self.objects_1, part)
            os.mkdir(self.parts_1[part])
        _create_test_rings(self.testdir)
        self.conf = dict(
            swift_dir=self.testdir, devices=self.devices, mount_check='false',
            timeout='300', stats_interval='1', sync_method='rsync')
        self.replicator = object_replicator.ObjectReplicator(self.conf)
        self.logger = self.replicator.logger = debug_logger('test-replicator')
        self.df_mgr = diskfile.DiskFileManager(self.conf,
                                               self.replicator.logger)

    def tearDown(self):
        rmtree(self.testdir, ignore_errors=1)

    def test_run_once(self):
        conf = dict(swift_dir=self.testdir, devices=self.devices,
                    mount_check='false', timeout='300', stats_interval='1')
        replicator = object_replicator.ObjectReplicator(conf)
        was_connector = object_replicator.http_connect
        object_replicator.http_connect = mock_http_connect(200)
        cur_part = '0'
        df = self.df_mgr.get_diskfile('sda', cur_part, 'a', 'c', 'o',
                                      policy=POLICIES[0])
        mkdirs(df._datadir)
        f = open(os.path.join(df._datadir,
                              normalize_timestamp(time.time()) + '.data'),
                 'wb')
        f.write('1234567890')
        f.close()
        ohash = hash_path('a', 'c', 'o')
        data_dir = ohash[-3:]
        whole_path_from = os.path.join(self.objects, cur_part, data_dir)
        process_arg_checker = []
        ring = replicator.load_object_ring(POLICIES[0])
        nodes = [node for node in
                 ring.get_part_nodes(int(cur_part))
                 if node['ip'] not in _ips()]
        rsync_mods = tuple(['%s::object/sda/objects/%s' %
                            (node['ip'], cur_part) for node in nodes])
        for node in nodes:
            process_arg_checker.append(
                (0, '', ['rsync', whole_path_from, rsync_mods]))
        with _mock_process(process_arg_checker):
            replicator.run_once()
        self.assertFalse(process_errors)
        object_replicator.http_connect = was_connector

    # policy 1
    def test_run_once_1(self):
        conf = dict(swift_dir=self.testdir, devices=self.devices,
                    mount_check='false', timeout='300', stats_interval='1')
        replicator = object_replicator.ObjectReplicator(conf)
        was_connector = object_replicator.http_connect
        object_replicator.http_connect = mock_http_connect(200)
        cur_part = '0'
        df = self.df_mgr.get_diskfile('sda', cur_part, 'a', 'c', 'o',
                                      policy=POLICIES[1])
        mkdirs(df._datadir)
        f = open(os.path.join(df._datadir,
                              normalize_timestamp(time.time()) + '.data'),
                 'wb')
        f.write('1234567890')
        f.close()
        ohash = hash_path('a', 'c', 'o')
        data_dir = ohash[-3:]
        whole_path_from = os.path.join(self.objects_1, cur_part, data_dir)
        process_arg_checker = []
        ring = replicator.load_object_ring(POLICIES[1])
        nodes = [node for node in
                 ring.get_part_nodes(int(cur_part))
                 if node['ip'] not in _ips()]
        rsync_mods = tuple(['%s::object/sda/objects-1/%s' %
                            (node['ip'], cur_part) for node in nodes])
        for node in nodes:
            process_arg_checker.append(
                (0, '', ['rsync', whole_path_from, rsync_mods]))
        with _mock_process(process_arg_checker):
            replicator.run_once()
        self.assertFalse(process_errors)
        object_replicator.http_connect = was_connector

    def test_check_ring(self):
        for pol in POLICIES:
            obj_ring = self.replicator.load_object_ring(pol)
            self.assertTrue(self.replicator.check_ring(obj_ring))
            orig_check = self.replicator.next_check
            self.replicator.next_check = orig_check - 30
            self.assertTrue(self.replicator.check_ring(obj_ring))
            self.replicator.next_check = orig_check
            orig_ring_time = obj_ring._mtime
            obj_ring._mtime = orig_ring_time - 30
            self.assertTrue(self.replicator.check_ring(obj_ring))
            self.replicator.next_check = orig_check - 30
            self.assertFalse(self.replicator.check_ring(obj_ring))

    def test_collect_jobs_mkdirs_error(self):

        non_local = {}

        def blowup_mkdirs(path):
            non_local['path'] = path
            raise OSError('Ow!')

        with mock.patch.object(object_replicator, 'mkdirs', blowup_mkdirs):
            rmtree(self.objects, ignore_errors=1)
            object_replicator.mkdirs = blowup_mkdirs
            self.replicator.collect_jobs()
            self.assertEqual(self.logger.get_lines_for_level('error'), [
                'ERROR creating %s: ' % non_local['path']])
            log_args, log_kwargs = self.logger.log_dict['error'][0]
            self.assertEqual(str(log_kwargs['exc_info'][1]), 'Ow!')

    def test_collect_jobs(self):
        jobs = self.replicator.collect_jobs()
        jobs_to_delete = [j for j in jobs if j['delete']]
        jobs_by_pol_part = {}
        for job in jobs:
            jobs_by_pol_part[str(int(job['policy'])) + job['partition']] = job
        self.assertEquals(len(jobs_to_delete), 2)
        self.assertTrue('1', jobs_to_delete[0]['partition'])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['00']['nodes']], [1, 2])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['01']['nodes']],
            [1, 2, 3])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['02']['nodes']], [2, 3])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['03']['nodes']], [3, 1])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['10']['nodes']], [1, 2])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['11']['nodes']],
            [1, 2, 3])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['12']['nodes']], [2, 3])
        self.assertEquals(
            [node['id'] for node in jobs_by_pol_part['13']['nodes']], [3, 1])
        for part in ['00', '01', '02', '03', ]:
            for node in jobs_by_pol_part[part]['nodes']:
                self.assertEquals(node['device'], 'sda')
            self.assertEquals(jobs_by_pol_part[part]['path'],
                              os.path.join(self.objects, part[1:]))
        for part in ['10', '11', '12', '13', ]:
            for node in jobs_by_pol_part[part]['nodes']:
                self.assertEquals(node['device'], 'sda')
            self.assertEquals(jobs_by_pol_part[part]['path'],
                              os.path.join(self.objects_1, part[1:]))

    def test_collect_jobs_handoffs_first(self):
        self.replicator.handoffs_first = True
        jobs = self.replicator.collect_jobs()
        self.assertTrue(jobs[0]['delete'])
        self.assertEquals('1', jobs[0]['partition'])

    def test_replicator_skips_bogus_partition_dirs(self):
        # A directory in the wrong place shouldn't crash the replicator
        rmtree(self.objects)
        rmtree(self.objects_1)
        os.mkdir(self.objects)
        os.mkdir(self.objects_1)

        os.mkdir(os.path.join(self.objects, "burrito"))
        jobs = self.replicator.collect_jobs()
        self.assertEqual(len(jobs), 0)

    def test_replicator_removes_zbf(self):
        # After running xfs_repair, a partition directory could become a
        # zero-byte file. If this happens, the replicator should clean it
        # up, log something, and move on to the next partition.

        # Surprise! Partition dir 1 is actually a zero-byte file.
        pol_0_part_1_path = os.path.join(self.objects, '1')
        rmtree(pol_0_part_1_path)
        with open(pol_0_part_1_path, 'w'):
            pass
        self.assertTrue(os.path.isfile(pol_0_part_1_path))  # sanity check

        # Policy 1's partition dir 1 is also a zero-byte file.
        pol_1_part_1_path = os.path.join(self.objects_1, '1')
        rmtree(pol_1_part_1_path)
        with open(pol_1_part_1_path, 'w'):
            pass
        self.assertTrue(os.path.isfile(pol_1_part_1_path))  # sanity check

        # Don't delete things in collect_jobs(); all the stat() calls would
        # make replicator startup really slow.
        self.replicator.collect_jobs()
        self.assertTrue(os.path.exists(pol_0_part_1_path))
        self.assertTrue(os.path.exists(pol_1_part_1_path))

        # After a replication pass, the files should be gone
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            self.replicator.run_once()

        self.assertFalse(os.path.exists(pol_0_part_1_path))
        self.assertFalse(os.path.exists(pol_1_part_1_path))
        self.assertEqual(
            sorted(self.logger.get_lines_for_level('warning')), [
                ('Removing partition directory which was a file: %s'
                 % pol_1_part_1_path),
                ('Removing partition directory which was a file: %s'
                 % pol_0_part_1_path),
            ])

    def test_delete_partition(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for node in nodes:
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                process_arg_checker.append(
                    (0, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_partition_default_sync_method(self):
        self.replicator.conf.pop('sync_method')
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for node in nodes:
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                process_arg_checker.append(
                    (0, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_partition_ssync_single_region(self):
        devs = [
            {'id': 0, 'device': 'sda', 'zone': 0,
             'region': 1, 'ip': '127.0.0.0', 'port': 6000},
            {'id': 1, 'device': 'sda', 'zone': 1,
             'region': 1, 'ip': '127.0.0.1', 'port': 6000},
            {'id': 2, 'device': 'sda', 'zone': 2,
             'region': 1, 'ip': '127.0.0.2', 'port': 6000},
            {'id': 3, 'device': 'sda', 'zone': 4,
             'region': 1, 'ip': '127.0.0.3', 'port': 6000},
            {'id': 4, 'device': 'sda', 'zone': 5,
             'region': 1, 'ip': '127.0.0.4', 'port': 6000},
            {'id': 5, 'device': 'sda', 'zone': 6,
             'region': 1, 'ip': 'fe80::202:b3ff:fe1e:8329', 'port': 6000},
            {'id': 6, 'device': 'sda', 'zone': 7, 'region': 1,
             'ip': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'port': 6000},
        ]
        _create_test_rings(self.testdir, devs=devs)
        self.conf['sync_method'] = 'ssync'
        self.replicator = object_replicator.ObjectReplicator(self.conf)
        self.replicator.logger = debug_logger()

        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            ts = normalize_timestamp(time.time())
            f = open(os.path.join(df._datadir, ts + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            whole_path_from = storage_directory(self.objects, 1, ohash)
            suffix_dir_path = os.path.dirname(whole_path_from)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))

            def _fake_ssync(node, job, suffixes, **kwargs):
                return True, {ohash: ts}

            self.replicator.sync_method = _fake_ssync
            self.replicator.replicate()
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertFalse(os.access(suffix_dir_path, os.F_OK))
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_partition_1(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES[1])
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects_1, '1', data_dir)
            part_path = os.path.join(self.objects_1, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[1])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for node in nodes:
                rsync_mod = '%s::object/sda/objects-1/%s' % (node['ip'], 1)
                process_arg_checker.append(
                    (0, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_partition_with_failures(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for i, node in enumerate(nodes):
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                if i == 0:
                    # force one of the rsync calls to fail
                    ret_code = 1
                else:
                    ret_code = 0
                process_arg_checker.append(
                    (ret_code, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            # The path should still exist
            self.assertTrue(os.access(part_path, os.F_OK))

    def test_delete_partition_with_handoff_delete(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            self.replicator.handoff_delete = 2
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for i, node in enumerate(nodes):
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                if i == 0:
                    # force one of the rsync calls to fail
                    ret_code = 1
                else:
                    ret_code = 0
                process_arg_checker.append(
                    (ret_code, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_partition_with_handoff_delete_failures(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            self.replicator.handoff_delete = 2
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for i, node in enumerate(nodes):
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                if i in (0, 1):
                    # force two of the rsync calls to fail
                    ret_code = 1
                else:
                    ret_code = 0
                process_arg_checker.append(
                    (ret_code, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(part_path, os.F_OK))

    def test_delete_partition_with_handoff_delete_fail_in_other_region(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, '1', data_dir)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            ring = self.replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(1)
                     if node['ip'] not in _ips()]
            process_arg_checker = []
            for node in nodes:
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'], 1)
                if node['region'] != 1:
                    #  the rsync calls for other region to fail
                    ret_code = 1
                else:
                    ret_code = 0
                process_arg_checker.append(
                    (ret_code, '', ['rsync', whole_path_from, rsync_mod]))
            with _mock_process(process_arg_checker):
                self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(part_path, os.F_OK))

    def test_delete_partition_override_params(self):
        df = self.df_mgr.get_diskfile('sda', '0', 'a', 'c', 'o',
                                      policy=POLICIES.legacy)
        mkdirs(df._datadir)
        part_path = os.path.join(self.objects, '1')
        self.assertTrue(os.access(part_path, os.F_OK))
        self.replicator.replicate(override_devices=['sdb'])
        self.assertTrue(os.access(part_path, os.F_OK))
        self.replicator.replicate(override_partitions=['9'])
        self.assertTrue(os.access(part_path, os.F_OK))
        self.replicator.replicate(override_devices=['sda'],
                                  override_partitions=['1'])
        self.assertFalse(os.access(part_path, os.F_OK))

    def test_delete_policy_override_params(self):
        df0 = self.df_mgr.get_diskfile('sda', '99', 'a', 'c', 'o',
                                       policy=POLICIES.legacy)
        df1 = self.df_mgr.get_diskfile('sda', '99', 'a', 'c', 'o',
                                       policy=POLICIES[1])
        mkdirs(df0._datadir)
        mkdirs(df1._datadir)

        pol0_part_path = os.path.join(self.objects, '99')
        pol1_part_path = os.path.join(self.objects_1, '99')

        # sanity checks
        self.assertTrue(os.access(pol0_part_path, os.F_OK))
        self.assertTrue(os.access(pol1_part_path, os.F_OK))

        # a bogus policy index doesn't bother the replicator any more than a
        # bogus device or partition does
        self.replicator.run_once(policies='1,2,5')

        self.assertFalse(os.access(pol1_part_path, os.F_OK))
        self.assertTrue(os.access(pol0_part_path, os.F_OK))

    def test_delete_partition_ssync(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            ts = normalize_timestamp(time.time())
            f = open(os.path.join(df._datadir, ts + '.data'),
                     'wb')
            f.write('0')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            whole_path_from = storage_directory(self.objects, 1, ohash)
            suffix_dir_path = os.path.dirname(whole_path_from)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))

            self.call_nums = 0
            self.conf['sync_method'] = 'ssync'

            def _fake_ssync(node, job, suffixes, **kwargs):
                success = True
                ret_val = {ohash: ts}
                if self.call_nums == 2:
                    # ssync should return (True, []) only when the second
                    # candidate node has not get the replica yet.
                    success = False
                    ret_val = {}
                self.call_nums += 1
                return success, ret_val

            self.replicator.sync_method = _fake_ssync
            self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            self.replicator.replicate()
            # The file should be deleted at the second replicate call
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertFalse(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            self.replicator.replicate()
            # The partition should be deleted at the third replicate call
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertFalse(os.access(suffix_dir_path, os.F_OK))
            self.assertFalse(os.access(part_path, os.F_OK))
            del self.call_nums

    def test_delete_partition_ssync_with_sync_failure(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            ts = normalize_timestamp(time.time())
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
            f.write('0')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            whole_path_from = storage_directory(self.objects, 1, ohash)
            suffix_dir_path = os.path.dirname(whole_path_from)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            self.call_nums = 0
            self.conf['sync_method'] = 'ssync'

            def _fake_ssync(node, job, suffixes, **kwags):
                success = False
                ret_val = {}
                if self.call_nums == 2:
                    # ssync should return (True, []) only when the second
                    # candidate node has not get the replica yet.
                    success = True
                    ret_val = {ohash: ts}
                self.call_nums += 1
                return success, ret_val

            self.replicator.sync_method = _fake_ssync
            self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            del self.call_nums

    def test_delete_objs_ssync_only_when_in_sync(self):
        self.replicator.logger = debug_logger('test-replicator')
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            ts = normalize_timestamp(time.time())
            f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
            f.write('0')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            whole_path_from = storage_directory(self.objects, 1, ohash)
            suffix_dir_path = os.path.dirname(whole_path_from)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))
            self.call_nums = 0
            self.conf['sync_method'] = 'ssync'

            in_sync_objs = {}

            def _fake_ssync(node, job, suffixes, remote_check_objs=None):
                self.call_nums += 1
                if remote_check_objs is None:
                    # sync job
                    ret_val = {ohash: ts}
                else:
                    ret_val = in_sync_objs
                return True, ret_val

            self.replicator.sync_method = _fake_ssync
            self.replicator.replicate()
            self.assertEqual(3, self.call_nums)
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))

            del self.call_nums

    def test_delete_partition_ssync_with_cleanup_failure(self):
        with mock.patch('swift.obj.replicator.http_connect',
                        mock_http_connect(200)):
            self.replicator.logger = mock_logger = \
                debug_logger('test-replicator')
            df = self.df_mgr.get_diskfile('sda', '1', 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            ts = normalize_timestamp(time.time())
            f = open(os.path.join(df._datadir, ts + '.data'), 'wb')
            f.write('0')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            whole_path_from = storage_directory(self.objects, 1, ohash)
            suffix_dir_path = os.path.dirname(whole_path_from)
            part_path = os.path.join(self.objects, '1')
            self.assertTrue(os.access(part_path, os.F_OK))

            self.call_nums = 0
            self.conf['sync_method'] = 'ssync'

            def _fake_ssync(node, job, suffixes, **kwargs):
                success = True
                ret_val = {ohash: ts}
                if self.call_nums == 2:
                    # ssync should return (True, []) only when the second
                    # candidate node has not get the replica yet.
                    success = False
                    ret_val = {}
                self.call_nums += 1
                return success, ret_val

            rmdir_func = os.rmdir

            def raise_exception_rmdir(exception_class, error_no):
                instance = exception_class()
                instance.errno = error_no

                def func(directory):
                    if directory == suffix_dir_path:
                        raise instance
                    else:
                        rmdir_func(directory)

                return func

            self.replicator.sync_method = _fake_ssync
            self.replicator.replicate()
            # The file should still exist
            self.assertTrue(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))

            # Fail with ENOENT
            with mock.patch('os.rmdir',
                            raise_exception_rmdir(OSError, ENOENT)):
                self.replicator.replicate()
            self.assertFalse(mock_logger.get_lines_for_level('error'))
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))

            # Fail with ENOTEMPTY
            with mock.patch('os.rmdir',
                            raise_exception_rmdir(OSError, ENOTEMPTY)):
                self.replicator.replicate()
            self.assertFalse(mock_logger.get_lines_for_level('error'))
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))

            # Fail with ENOTDIR
            with mock.patch('os.rmdir',
                            raise_exception_rmdir(OSError, ENOTDIR)):
                self.replicator.replicate()
            self.assertEqual(len(mock_logger.get_lines_for_level('error')), 1)
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertTrue(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))

            # Finally we can cleanup everything
            self.replicator.replicate()
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertFalse(os.access(suffix_dir_path, os.F_OK))
            self.assertTrue(os.access(part_path, os.F_OK))
            self.replicator.replicate()
            self.assertFalse(os.access(whole_path_from, os.F_OK))
            self.assertFalse(os.access(suffix_dir_path, os.F_OK))
            self.assertFalse(os.access(part_path, os.F_OK))

    def test_run_once_recover_from_failure(self):
        conf = dict(swift_dir=self.testdir, devices=self.devices,
                    mount_check='false', timeout='300', stats_interval='1')
        replicator = object_replicator.ObjectReplicator(conf)
        was_connector = object_replicator.http_connect
        try:
            object_replicator.http_connect = mock_http_connect(200)
            # Write some files into '1' and run replicate- they should be moved
            # to the other partitions and then node should get deleted.
            cur_part = '1'
            df = self.df_mgr.get_diskfile('sda', cur_part, 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, cur_part, data_dir)
            ring = replicator.load_object_ring(POLICIES[0])
            process_arg_checker = []
            nodes = [node for node in
                     ring.get_part_nodes(int(cur_part))
                     if node['ip'] not in _ips()]
            for node in nodes:
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'],
                                                           cur_part)
                process_arg_checker.append(
                    (0, '', ['rsync', whole_path_from, rsync_mod]))
            self.assertTrue(os.access(os.path.join(self.objects,
                                                   '1', data_dir, ohash),
                                      os.F_OK))
            with _mock_process(process_arg_checker):
                replicator.run_once()
            self.assertFalse(process_errors)
            for i, result in [('0', True), ('1', False),
                              ('2', True), ('3', True)]:
                self.assertEquals(os.access(
                    os.path.join(self.objects,
                                 i, diskfile.HASH_FILE),
                    os.F_OK), result)
        finally:
            object_replicator.http_connect = was_connector

    def test_run_once_recover_from_timeout(self):
        conf = dict(swift_dir=self.testdir, devices=self.devices,
                    mount_check='false', timeout='300', stats_interval='1')
        replicator = object_replicator.ObjectReplicator(conf)
        was_connector = object_replicator.http_connect
        was_get_hashes = object_replicator.get_hashes
        was_execute = tpool.execute
        self.get_hash_count = 0
        try:

            def fake_get_hashes(*args, **kwargs):
                self.get_hash_count += 1
                if self.get_hash_count == 3:
                    # raise timeout on last call to get hashes
                    raise Timeout()
                return 2, {'abc': 'def'}

            def fake_exc(tester, *args, **kwargs):
                if 'Error syncing partition' in args[0]:
                    tester.i_failed = True

            self.i_failed = False
            object_replicator.http_connect = mock_http_connect(200)
            object_replicator.get_hashes = fake_get_hashes
            replicator.logger.exception = \
                lambda *args, **kwargs: fake_exc(self, *args, **kwargs)
            # Write some files into '1' and run replicate- they should be moved
            # to the other partitions and then node should get deleted.
            cur_part = '1'
            df = self.df_mgr.get_diskfile('sda', cur_part, 'a', 'c', 'o',
                                          policy=POLICIES.legacy)
            mkdirs(df._datadir)
            f = open(os.path.join(df._datadir,
                                  normalize_timestamp(time.time()) + '.data'),
                     'wb')
            f.write('1234567890')
            f.close()
            ohash = hash_path('a', 'c', 'o')
            data_dir = ohash[-3:]
            whole_path_from = os.path.join(self.objects, cur_part, data_dir)
            process_arg_checker = []
            ring = replicator.load_object_ring(POLICIES[0])
            nodes = [node for node in
                     ring.get_part_nodes(int(cur_part))
                     if node['ip'] not in _ips()]

            for node in nodes:
                rsync_mod = '%s::object/sda/objects/%s' % (node['ip'],
                                                           cur_part)
                process_arg_checker.append(
                    (0, '', ['rsync', whole_path_from, rsync_mod]))
            self.assertTrue(os.access(os.path.join(self.objects,
                                                   '1', data_dir, ohash),
                                      os.F_OK))
            with _mock_process(process_arg_checker):
                replicator.run_once()
            self.assertFalse(process_errors)
            self.assertFalse(self.i_failed)
        finally:
            object_replicator.http_connect = was_connector
            object_replicator.get_hashes = was_get_hashes
            tpool.execute = was_execute

    def test_run(self):
        with _mock_process([(0, '')] * 100):
            with mock.patch('swift.obj.replicator.http_connect',
                            mock_http_connect(200)):
                self.replicator.replicate()

    def test_run_withlog(self):
        with _mock_process([(0, "stuff in log")] * 100):
            with mock.patch('swift.obj.replicator.http_connect',
                            mock_http_connect(200)):
                self.replicator.replicate()

    def test_sync_just_calls_sync_method(self):
        self.replicator.sync_method = mock.MagicMock()
        self.replicator.sync('node', 'job', 'suffixes')
        self.replicator.sync_method.assert_called_once_with(
            'node', 'job', 'suffixes')

    @mock.patch('swift.obj.replicator.tpool_reraise', autospec=True)
    @mock.patch('swift.obj.replicator.http_connect', autospec=True)
    def test_update(self, mock_http, mock_tpool_reraise):

        def set_default(self):
            self.replicator.suffix_count = 0
            self.replicator.suffix_sync = 0
            self.replicator.suffix_hash = 0
            self.replicator.replication_count = 0
            self.replicator.partition_times = []

        self.headers = {'Content-Length': '0',
                        'user-agent': 'object-replicator %s' % os.getpid()}
        self.replicator.logger = mock_logger = mock.MagicMock()
        mock_tpool_reraise.return_value = (0, {})

        all_jobs = self.replicator.collect_jobs()
        jobs = [job for job in all_jobs if not job['delete']]

        mock_http.return_value = answer = mock.MagicMock()
        answer.getresponse.return_value = resp = mock.MagicMock()
        # Check uncorrect http_connect with status 507 and
        # count of attempts and call args
        resp.status = 507
        error = '%(ip)s/%(device)s responded as unmounted'
        expect = 'Error syncing partition'
        for job in jobs:
            set_default(self)
            ring = job['policy'].object_ring
            self.headers['X-Backend-Storage-Policy-Index'] = int(job['policy'])
            self.replicator.update(job)
            self.assertTrue(error in mock_logger.error.call_args[0][0])
            self.assertTrue(expect in mock_logger.exception.call_args[0][0])
            self.assertEquals(len(self.replicator.partition_times), 1)
            self.assertEquals(mock_http.call_count, len(ring._devs) - 1)
            reqs = []
            for node in job['nodes']:
                reqs.append(mock.call(node['ip'], node['port'], node['device'],
                                      job['partition'], 'REPLICATE', '',
                                      headers=self.headers))
            if job['partition'] == '0':
                self.assertEquals(self.replicator.suffix_hash, 0)
            mock_http.assert_has_calls(reqs, any_order=True)
            mock_http.reset_mock()
            mock_logger.reset_mock()

        # Check uncorrect http_connect with status 400 != HTTP_OK
        resp.status = 400
        error = 'Invalid response %(resp)s from %(ip)s'
        for job in jobs:
            set_default(self)
            self.replicator.update(job)
            self.assertTrue(error in mock_logger.error.call_args[0][0])
            self.assertEquals(len(self.replicator.partition_times), 1)
            mock_logger.reset_mock()

        # Check successful http_connection and exception with
        # uncorrect pickle.loads(resp.read())
        resp.status = 200
        expect = 'Error syncing with node:'
        for job in jobs:
            set_default(self)
            self.replicator.update(job)
            self.assertTrue(expect in mock_logger.exception.call_args[0][0])
            self.assertEquals(len(self.replicator.partition_times), 1)
            mock_logger.reset_mock()

        # Check successful http_connection and correct
        # pickle.loads(resp.read()) for non local node
        resp.status = 200
        local_job = None
        resp.read.return_value = pickle.dumps({})
        for job in jobs:
            set_default(self)
            # limit local job to policy 0 for simplicity
            if job['partition'] == '0' and int(job['policy']) == 0:
                local_job = job.copy()
                continue
            self.replicator.update(job)
            self.assertEquals(mock_logger.exception.call_count, 0)
            self.assertEquals(mock_logger.error.call_count, 0)
            self.assertEquals(len(self.replicator.partition_times), 1)
            self.assertEquals(self.replicator.suffix_hash, 0)
            self.assertEquals(self.replicator.suffix_sync, 0)
            self.assertEquals(self.replicator.suffix_count, 0)
            mock_logger.reset_mock()

        # Check successful http_connect and sync for local node
        mock_tpool_reraise.return_value = (1, {'a83': 'ba47fd314242ec8c'
                                                      '7efb91f5d57336e4'})
        resp.read.return_value = pickle.dumps({'a83': 'c130a2c17ed45102a'
                                                      'ada0f4eee69494ff'})
        set_default(self)
        self.replicator.sync = fake_func = \
            mock.MagicMock(return_value=(True, []))
        self.replicator.update(local_job)
        reqs = []
        for node in local_job['nodes']:
            reqs.append(mock.call(node, local_job, ['a83']))
        fake_func.assert_has_calls(reqs, any_order=True)
        self.assertEquals(fake_func.call_count, 2)
        self.assertEquals(self.replicator.replication_count, 1)
        self.assertEquals(self.replicator.suffix_sync, 2)
        self.assertEquals(self.replicator.suffix_hash, 1)
        self.assertEquals(self.replicator.suffix_count, 1)

        # Efficient Replication Case
        set_default(self)
        self.replicator.sync = fake_func = \
            mock.MagicMock(return_value=(True, []))
        all_jobs = self.replicator.collect_jobs()
        job = None
        for tmp in all_jobs:
            if tmp['partition'] == '3':
                job = tmp
                break
        # The candidate nodes to replicate (i.e. dev1 and dev3)
        # belong to another region
        self.replicator.update(job)
        self.assertEquals(fake_func.call_count, 1)
        self.assertEquals(self.replicator.replication_count, 1)
        self.assertEquals(self.replicator.suffix_sync, 1)
        self.assertEquals(self.replicator.suffix_hash, 1)
        self.assertEquals(self.replicator.suffix_count, 1)

        mock_http.reset_mock()
        mock_logger.reset_mock()

        # test for replication params on policy 0 only
        repl_job = local_job.copy()
        for node in repl_job['nodes']:
            node['replication_ip'] = '127.0.0.11'
            node['replication_port'] = '6011'
        set_default(self)
        # with only one set of headers make sure we specify index 0 here
        # as otherwise it may be different from earlier tests
        self.headers['X-Backend-Storage-Policy-Index'] = 0
        self.replicator.update(repl_job)
        reqs = []
        for node in repl_job['nodes']:
            reqs.append(mock.call(node['replication_ip'],
                                  node['replication_port'], node['device'],
                                  repl_job['partition'], 'REPLICATE',
                                  '', headers=self.headers))
            reqs.append(mock.call(node['replication_ip'],
                                  node['replication_port'], node['device'],
                                  repl_job['partition'], 'REPLICATE',
                                  '/a83', headers=self.headers))
        mock_http.assert_has_calls(reqs, any_order=True)

if __name__ == '__main__':
    unittest.main()


text:
Augmented Reality-like Website Editing (Sponsor)
Tharzen Inc. builds on University of Chicago's bidirectional programming patent to provide a folder to upload on websites. It enables appending ?edit to web addresses and, after logging, it serves webpages augmented with some toolbars and editing capabilities. Our A.I. supports full static HTML, a subset of PHP and statically generated websites via Hyde Build Tool; With a bit of work it works even if some JavaScript is present.
We Spoke To Uber Drivers Who Have Taken Over The Company's Offices In France (11 minute read)
Uber drivers across France have occupied or shut down many of the company's Greenlight Hubs in order to negotiate better working conditions. Greenlight Hubs are facilities where new drivers can be registered and be onboarded, and where existing drivers can get in-person support. Uber has attempted to move its operations over to hotels and co-working spaces. As the company grew, it increased its own cut of fares and decreased the minimum fares for trips. The drivers have nine demands in their protest. They want a driver cap and a study on Uber's market effects, dynamic pricing instead of fixed pricing, an increase in the minimum driver fare, pay for time spent driving to pick up passengers, an increase in the base pay rate, union representation, removal of the penalty for cancelling trips, the ability to review trip prices and destinations before cancelling, and a driver verification system.
Google Photos finally lets you manually tag people in pictures (1 minute read)
Users will be able to start manually tagging people in Google Photos. Previously, Photos automatically recognized faces and sorted them, but the system sometimes missed faces and users would not be able to correct the mistakes. Users can only tag faces if the system recognizes a face in the photo. Google automatically scans photos for faces if the 'face grouping' feature is turned on. It doesn't share information between accounts. If users turn off the 'face grouping' feature, the face models that have been generated for the account will be deleted.
Call to probe Boston police tests of 'dog' robots (2 minute read)
Massachusetts State Police have been testing Boston Dynamic's Spot robot dogs in the past three months. The American Civil Liberties Union launching and enquiry as there are no regulations governing the use of the robots and they want to ensure that the use of the robots will not trample on established civil rights and liberties or lead to racial injustice. The Massachusetts State Police stated that the robots were being used as mobile remote observation devices to look at suspicious devices or locations that might be hazardous for human officers. Spot has been used in two incidents, working with the organization's bomb squad. Boston Dynamics leased the robots to the police in order to retain control over how they are used. There are explicit clauses in the lease that prevent the police from using the robots to physically harm or intimidate people.
2 Months After Failed Moon Landing, India Acknowledges Its Craft Crashed (2 minute read)
India sent a landing vehicle to the moon back in September in an attempt to make history, but the project ended inconclusively and there was no explanation of what happened at the time. Public updates only stated that the lander had been located and that no communication had been established with it yet. The Indian government has now released a statement that revealed that the Vikram lander had malfunctioned, causing it to crash. The Chandrayaan-2 spacecraft continues to be successful in collecting information during its orbit around the moon.
Flowy (GitHub Repo)
Flowy is a JavaScript library that can create WebApps with flowchart functionality. It supports responsive drag and drop, automatic snapping, block rearrangement, deleting blocks, and automatic block centering. A gif demo is available on the repository and a link to a working demo is provided.
Iced (GitHub Repo)
Iced is a cross-platform GUI library for Rust that is focused on simplicity and type-safety. It features a simple API, a responsive layout, built-in widgets, a modular ecosystem, and more. Ice was inspired by the Elm Architecture and it is still an experimental software. Due to the speed of development, the master branch can contain breaking changes.
Ask HN: Quitting Big Tech, what is it like? (Hacker News Thread)
After spending a lot of time working in FAANG companies, it might be difficult to imagine what the environment is like on the outside. Making a lot of money usually comes at the cost of very high expectations and brutal deadlines. The tools available at FAANG companies are a great help to engineers, and developers might find it difficult to work in 'real world' companies after leaving due to the lack of support. Being previously employed at a FAANG company might help with investors and being hired, but the work itself will still be difficult. Many people who try to leave and work in startups eventually find that the minimal support and validation is not worth it and return to big tech.
Former Go champion beaten by DeepMind retires after declaring AI invincible (3 minute read)
Go champion Lee Se-dol has retired from professional play, stating that his decision was influenced by the rise of AI. Lee believes that no matter how good he gets at the game, there will always be an entity that he cannot defeat. For many years, Go was considered to be impossible for computer programs to master, as it has more possible configurations for pieces than atoms in the observable universe. In 2016, DeepMind's AlphaGo defeated Se-dol four matches to one. Lee is the only human to have ever beat AlphaGo in a tournament. In 2017, DeepMind released an improved version of AlphaGo called AlphaGo Zero. AlphaGo Zero was able to beat AlphaGo 100 games to nil after three days of training. Lee will play a game in December against a South Korean AI program called HanDol.


WSBRC receives and sources biological and geological information from a wide variety of individuals, organisations and schemes in a number of different formats. Information can be received in electronic formats such as spreadsheets, documents, databases and bespoke recording packages, or it can come to us in paper format such as notebooks, recording cards, ecological survey reports or notes. In addition habitat land-use data is interpreted from survey information, OS MasterMap tiles and aerial photos.
Where do our records come from?
Information on species, sites and habitats are gathered and interpreted from a wide variety of sources including published reports from ecological consultancies and researchers and commissioned surveys and data provided by other voluntary and statutory organisations; but most species records are collected by volunteers. These provide the majority of WSBRC's species records and we support our local recorders by providing them relevant tools and guidance to promote good practice in biological recording. A network of approved volunteer experts, the County Recorders, provide us with most specialist records and undertake records verification but we also rely upon general recorders to keep us up-to-date on what is happening in the county.
We recognise that the data we hold and provide needs to be as accurate as possible. However datasets do not represent complete coverage in terms of species or habitats present within the county. Site quality changes over time and species move in and out of areas – some with greater frequency than others. The data reflects a snapshot of what was present at the time of the survey or sighting, and so should be seen as a guide rather than a definitive statement of the condition of an area.
Data held by WSBRC is validated as fully as possible to ensure such factors as geographical and temporal accuracy of each record as well as formatting or inputting errors. Validation is done by manual checking as well as by automated routines within our database system. In addition, WSBRC staff and County Recorders, in particular, undertake verification of records ensuring that notable species or new records for an area are correctly identified.
Records will be accepted by WSBRC on the understanding that the data will be used by WSBRC and made available to enquirers under the terms and conditions set out within this section of our website.
We request that wherever possible biological data relating to Wiltshire & Swindon collected by users of our service is shared with WSBRC at the end of the project. Such information adds to the value of the existing data held by WSBRC and is in the interest of all parties.


MEP has put together an intelligent program that was well thought out and challenging for supply chain management team. They challenged our supply chain approach and current paradigm – forcing us to take a fresh look at what we do and how we do it. We are using the supply chain strategy tools that they provided as "take-aways" to change how we do things.