问:
Update an object from a list of destination derived classes with an object from a list of derived source classes using a generic converter
I have a list of source classes derived from a base source class and a list with destination classes derived from a base destination class. There is only one destination class corresponding to a source class. I want to make a generic converter which updates an existing destination object, given his corresponding source object.

Updated completely:

I have the following code:

```<code>using System;

namespace ConsoleApp1
{
    internal class Program
    {
    private static void Main(string[] args)
    {
        S1 newItem = new S1()
        {
            Age = 11,
            Name = "John"
        };

        D1 oldItem = new D1()
        {
            Age = 10
        };

        //there is an item in a database which is of D1 type. This convertor receives an object S1 in order to update the D1 item.
        // the rule is that Sx updatates Dx (where x is 1,2,3,4,5...)
        Convertor<S1, D1> convertor = new Convertor<S1, D1>(newItem, oldItem);

        S2 newItem2 = new S2()
        {
            City = "London",
            Name = "Lynda"
        };

        D2 oldItem2 = new D2()
        {
            City = "Paris"
        };

        Convertor<S2, D2> convertor2 = new Convertor<S2, D2>(newItem2, oldItem2);
        Console.ReadKey();
    }
}

public abstract class SourceDomain
{
    public string Name { get; set; }
    internal abstract void SetItem<Y>(Y oldItem) where Y : DestinationDomain;
}

public class S1 : SourceDomain
{
    public int Age { get; set; }

    internal override void SetItem<Y>(Y oldItem)
    {
        Console.WriteLine("here I want to update the age of oldItem (10) with the new value (11)");
        //oldItem.Age = Age;
    }
}

public class S2 : SourceDomain
{
    public string City { get; set; }

    internal override void SetItem<Y>(Y oldItem)
    {
        Console.WriteLine("here I want to update the city of oldItem Paris with the new value London");
        // oldItem.City = City;
    }
}

public class DestinationDomain { }
public class D1 : DestinationDomain
{
    public int Age { get; set; }
}
public class D2 : DestinationDomain
{
    public string City { get; set; }
}

public class Convertor<X, Y> where X : SourceDomain where Y : DestinationDomain
{
    protected X item;
    protected Y oldItem;

    public Convertor(X newObject, Y oldObject)
    {
        item = newObject;
        oldItem = oldObject;

        //here I want to call, depending of item type, the proper method, not the base one.
        item.SetItem(oldItem);
    }
}
</code>```

}

SourceDomain and DestinationDomain are base classes and there are a lot of derived classes for each of them S1, S2, D1, D2, etc.

This converter receives two classes as types and two objects of that classes and tries to update the destination item of type Y with source item of type X.

In the above example, I want to change update the age of the D1 oldItem variable with 11, and the City oldItem2 with the "London" value, but I cannot access that properties in SetItem method.

答:
This needs to be done with a combination of inheritance and generics, and we'll make the two work together with generic type constraints.

Here are the requirements as I understand them:

You've got some data you want to copy from Source to Destination; one kind of data has an Age, one has a City, maybe another has a Poodle or a SwimmingPool. We'll define an interface that says: "This is a data object which can copy its own properties from another object of the same type", and we'll put all our data in little classes which know how to copy themselves. The "I can copy things like me" interface doesn't know what properties will be copied; it just requires the concrete class to implement a method that knows those details internally. As far as this example goes it could be a base class, but my assumption is the “copyability” isn’t the core indentity of these objects. It’s not what they represent; it’s just one thing we need to be able to do with them along the way.

The other things we need are a "source thing", and a "destination thing". A source thing just needs to provide a data object that can be copied. A destination thing just needs to receive a data object that can be copied.

You confused yourself by trying to mix up the sources and destinations with the data items. If you're going crazy trying to make your class do two contradictory things at once, try breaking it up into two classes that each does one thing.

You never do anything with your SourceDomain Name property, so I won't either. If you need to, I'll leave that as an exercise.

```<code>public interface ICopyable<T>
{
    void CopyFrom(T other);
}

internal class Program
{
    private static void Main(string[] args)
    {
        var newItem = new SourceDomain<Person>
        {
            Item = new Person { Age = 11 },
            Name = "John"
        };

        var oldItem = new DestinationDomain<Person>
        {
            Item = new Person { Age = 10 }
        };

        //there is an item in a database which is of D1 type. This convertor receives an object S1 in order to update the D1 item.
        // the rule is that Sx updatates Dx (where x is 1,2,3,4,5...)
        Convertor<Person> convertor = new Convertor<Person>(newItem, oldItem);

        var newItem2 = new SourceDomain<Location>()
        {
            Item = new Location { City = "London" },
            Name = "Lynda"
        };

        var oldItem2 = new DestinationDomain<Location>()
        {
            Item = new Location {  City = "Paris" }
        };

        Convertor<Location> convertor2 = new Convertor<Location>(newItem2, oldItem2);
        Console.ReadKey();
    }
}

public class SourceDomain<T>
{
    public string Name { get; set; }
    public T Item { get; set;  }
}

public class DestinationDomain<T> where T : ICopyable<T>, new()
{
    public string Name { get; set; }

    public T Item { get; set; }
    public void CopyItemFrom(T other)
    {
        if (Item == null)
        {
            Item = new T();
        }
        Item.CopyFrom(other);
    }
}

//  A person is a thing which can turn itself into a copy of another Person.
//  You could define a class Wombat : ICopyable<Locomotive>, if you wanted to be
//  able to convert Locomotives to Wombats. You'd just add another CopyFrom()
//  overload, public void CopyFrom(Locomotive other).
public class Person : ICopyable<Person>
{
    public int Age { get; set; }

    public void CopyFrom(Person other)
    {
        Age = other.Age;
    }
}
public class Location : ICopyable<Location>
{
    public String City { get; set; }

    public void CopyFrom(Location other)
    {
        City = other.City;
    }
}

public class Convertor<X> where X : ICopyable<X>, new()
{
    protected SourceDomain<X> item;
    protected DestinationDomain<X> oldItem;

    public Convertor(SourceDomain<X> newObject, DestinationDomain<X> oldObject)
    {
        item = newObject;
        oldItem = oldObject;

        //here I want to call, depending of item type, the proper method, not the base one.
        //newObject.Data = oldItem.Data;
        oldItem.CopyItemFrom(item.Item);
    }
}
</code>```

Homework:

Modify this code so DestinationDomain.CopyItemFrom() receives the source itself, not the source's item.

I think it's better the way I wrote it. Think of reasons why I might have thought that.

Seriously, find out what ref does, and never again use a keyword in your code if you are only guessing about what it might mean. Don't just throw code at the wall, hoping it sticks. You'll get yourself in a lot of frustrating trouble that way.

Body:
I have a list of source classes derived from a base source class and a list with destination classes derived from a base destination class. There is only one destination class corresponding to a source class. I want to make a generic converter which updates an existing destination object, given his corresponding source object.

Updated completely:

I have the following code:

using System;

namespace ConsoleApp1
{
    internal class Program
    {
    private static void Main(string[] args)
    {
        S1 newItem = new S1()
        {
            Age = 11,
            Name = "John"
        };

        D1 oldItem = new D1()
        {
            Age = 10
        };

        //there is an item in a database which is of D1 type. This convertor receives an object S1 in order to update the D1 item.
        // the rule is that Sx updatates Dx (where x is 1,2,3,4,5...)
        Convertor<S1, D1> convertor = new Convertor<S1, D1>(newItem, oldItem);

        S2 newItem2 = new S2()
        {
            City = "London",
            Name = "Lynda"
        };

        D2 oldItem2 = new D2()
        {
            City = "Paris"
        };

        Convertor<S2, D2> convertor2 = new Convertor<S2, D2>(newItem2, oldItem2);
        Console.ReadKey();
    }
}

public abstract class SourceDomain
{
    public string Name { get; set; }
    internal abstract void SetItem<Y>(Y oldItem) where Y : DestinationDomain;
}

public class S1 : SourceDomain
{
    public int Age { get; set; }

    internal override void SetItem<Y>(Y oldItem)
    {
        Console.WriteLine("here I want to update the age of oldItem (10) with the new value (11)");
        //oldItem.Age = Age;
    }
}

public class S2 : SourceDomain
{
    public string City { get; set; }

    internal override void SetItem<Y>(Y oldItem)
    {
        Console.WriteLine("here I want to update the city of oldItem Paris with the new value London");
        // oldItem.City = City;
    }
}

public class DestinationDomain { }
public class D1 : DestinationDomain
{
    public int Age { get; set; }
}
public class D2 : DestinationDomain
{
    public string City { get; set; }
}

public class Convertor<X, Y> where X : SourceDomain where Y : DestinationDomain
{
    protected X item;
    protected Y oldItem;

    public Convertor(X newObject, Y oldObject)
    {
        item = newObject;
        oldItem = oldObject;

        //here I want to call, depending of item type, the proper method, not the base one.
        item.SetItem(oldItem);
    }
}

}

SourceDomain and DestinationDomain are base classes and there are a lot of derived classes for each of them S1, S2, D1, D2, etc.

This converter receives two classes as types and two objects of that classes and tries to update the destination item of type Y with source item of type X.

In the above example, I want to change update the age of the D1 oldItem variable with 11, and the City oldItem2 with the "London" value, but I cannot access that properties in SetItem method.

Body:
This needs to be done with a combination of inheritance and generics, and we'll make the two work together with generic type constraints.

Here are the requirements as I understand them:

You've got some data you want to copy from Source to Destination; one kind of data has an Age, one has a City, maybe another has a Poodle or a SwimmingPool. We'll define an interface that says: "This is a data object which can copy its own properties from another object of the same type", and we'll put all our data in little classes which know how to copy themselves. The "I can copy things like me" interface doesn't know what properties will be copied; it just requires the concrete class to implement a method that knows those details internally. As far as this example goes it could be a base class, but my assumption is the “copyability” isn’t the core indentity of these objects. It’s not what they represent; it’s just one thing we need to be able to do with them along the way.

The other things we need are a "source thing", and a "destination thing". A source thing just needs to provide a data object that can be copied. A destination thing just needs to receive a data object that can be copied.

You confused yourself by trying to mix up the sources and destinations with the data items. If you're going crazy trying to make your class do two contradictory things at once, try breaking it up into two classes that each does one thing.

You never do anything with your SourceDomain Name property, so I won't either. If you need to, I'll leave that as an exercise.

public interface ICopyable<T>
{
    void CopyFrom(T other);
}

internal class Program
{
    private static void Main(string[] args)
    {
        var newItem = new SourceDomain<Person>
        {
            Item = new Person { Age = 11 },
            Name = "John"
        };

        var oldItem = new DestinationDomain<Person>
        {
            Item = new Person { Age = 10 }
        };

        //there is an item in a database which is of D1 type. This convertor receives an object S1 in order to update the D1 item.
        // the rule is that Sx updatates Dx (where x is 1,2,3,4,5...)
        Convertor<Person> convertor = new Convertor<Person>(newItem, oldItem);

        var newItem2 = new SourceDomain<Location>()
        {
            Item = new Location { City = "London" },
            Name = "Lynda"
        };

        var oldItem2 = new DestinationDomain<Location>()
        {
            Item = new Location {  City = "Paris" }
        };

        Convertor<Location> convertor2 = new Convertor<Location>(newItem2, oldItem2);
        Console.ReadKey();
    }
}

public class SourceDomain<T>
{
    public string Name { get; set; }
    public T Item { get; set;  }
}

public class DestinationDomain<T> where T : ICopyable<T>, new()
{
    public string Name { get; set; }

    public T Item { get; set; }
    public void CopyItemFrom(T other)
    {
        if (Item == null)
        {
            Item = new T();
        }
        Item.CopyFrom(other);
    }
}

//  A person is a thing which can turn itself into a copy of another Person.
//  You could define a class Wombat : ICopyable<Locomotive>, if you wanted to be
//  able to convert Locomotives to Wombats. You'd just add another CopyFrom()
//  overload, public void CopyFrom(Locomotive other).
public class Person : ICopyable<Person>
{
    public int Age { get; set; }

    public void CopyFrom(Person other)
    {
        Age = other.Age;
    }
}
public class Location : ICopyable<Location>
{
    public String City { get; set; }

    public void CopyFrom(Location other)
    {
        City = other.City;
    }
}

public class Convertor<X> where X : ICopyable<X>, new()
{
    protected SourceDomain<X> item;
    protected DestinationDomain<X> oldItem;

    public Convertor(SourceDomain<X> newObject, DestinationDomain<X> oldObject)
    {
        item = newObject;
        oldItem = oldObject;

        //here I want to call, depending of item type, the proper method, not the base one.
        //newObject.Data = oldItem.Data;
        oldItem.CopyItemFrom(item.Item);
    }
}

Homework:

Modify this code so DestinationDomain.CopyItemFrom() receives the source itself, not the source's item.

I think it's better the way I wrote it. Think of reasons why I might have thought that.

Seriously, find out what ref does, and never again use a keyword in your code if you are only guessing about what it might mean. Don't just throw code at the wall, hoping it sticks. You'll get yourself in a lot of frustrating trouble that way.


来源: stackexchange

问:
Is it necessary to create a Copy Constructor for derived classes?
If i have a base class with a complex data member, let's say char*, and at the end of my inheritance chain I have another class with the same kind of DM, do i have to implement the CCTORs of all the other classes on the way?

for example:

Animal Class:

```<code>class Animal
{
    int age;
    char* name;
    Animal() { ... }
    Animal(const Animal &animal) { ..deep copying name..}
}
</code>```

Mammal Class:

```<code>class Mammal : public Animal
{
    int height;
    Mammal() { ... }
}
</code>```

Horse Class:

```<code>class Horse : public Mammal
{
    char* color;
    Horse() { ... }
    Horse(const Horse &horse ) { ..deep copying color..}
}
</code>```

Do i need to implement a CCTOR in Mammal, even though it has only an int as a data member?

Basically my question is: when copying a complex object (built from several classes), does the compiler activate the CCTOR of each part separately?

Edit:
To be clear, i want to copy a Horse object. If i write my code as above, will its name be deep copied as well?

答:
The problematic class members you have are the char* raw pointers.

In idiomatic c++ you can solve that problem using std::string instead, thus you don't need to specify any constructors:

```<code>class Animal
{
    int age;
    std::string name;
    Animal() = default; // not really neccessary, just for demonstration
                        // purpose
    Animal(const Animal &animal) = default; // not really neccessary, just for
                                            // demonstration purpose
};
</code>```

```<code>class Mammal : public Animal
{
    int height;
};
</code>```

```<code>class Horse : public Mammal
{
    std::string color;
};
</code>```

ContentLicense: CC BY-SA 4.0

Body:
If i have a base class with a complex data member, let's say char*, and at the end of my inheritance chain I have another class with the same kind of DM, do i have to implement the CCTORs of all the other classes on the way?

for example:

Animal Class:

class Animal
{
    int age;
    char* name;
    Animal() { ... }
    Animal(const Animal &animal) { ..deep copying name..}
}

Mammal Class:

class Mammal : public Animal
{
    int height;
    Mammal() { ... }
}

Horse Class:

class Horse : public Mammal
{
    char* color;
    Horse() { ... }
    Horse(const Horse &horse ) { ..deep copying color..}
}

Do i need to implement a CCTOR in Mammal, even though it has only an int as a data member?

Basically my question is: when copying a complex object (built from several classes), does the compiler activate the CCTOR of each part separately?

Edit:
To be clear, i want to copy a Horse object. If i write my code as above, will its name be deep copied as well?

Body:
The problematic class members you have are the char* raw pointers.

In idiomatic c++ you can solve that problem using std::string instead, thus you don't need to specify any constructors:

class Animal
{
    int age;
    std::string name;
    Animal() = default; // not really neccessary, just for demonstration
                        // purpose
    Animal(const Animal &animal) = default; // not really neccessary, just for
                                            // demonstration purpose
};

class Mammal : public Animal
{
    int height;
};

class Horse : public Mammal
{
    std::string color;
};


问:
Using Hunch on Google App engine
I want to use Hunch on Google App Engine in Python. What libraries do I need to use to do this or are there any good online tutorials that could help me with this?</p>

答:
Recently, mnn2104 wrote a Python wrapper for the Hunch API called HunchPY.

As for tutorials, a good place to start is the the Hunch Developer homepage and Hunch's Github profile.

ContentLicense: CC BY-SA 3.0

Title: Using Hunch on Google App engine


问:
How can I store and return data from an HTTP response?
I am using the request module to make a request to an API which sends me a Base64 encoded response which is a file.

```<code>    app.get("/report", async(request, response) => {
    const newRequest = new mdl.Request
    const newDatasources = new  mdl.Datasources
    const newVariables = new mdl.VariablesType
    const VariablesArray = []
    const myArray = []

    newRequest.Uri = "http://127.0.0.1:8080/listing.docx"
 newRequest.Async = false
    newRequest.OutputFormat = "html"
    newVariables.Name = "Var1"
    newVariables.Type = "text"
    newVariables.Value = "Hello World!"
    VariablesArray.push(newVariables)
    newDatasources.Name = "JSON"
    newDatasources.Type = "JSON"
    newDatasources.Data = "ewogICAgImxpc3RQcmljZSI6ICIkODc5LDAwMCIsCiAAgICAgInB1cmNoQ29udHJhY3REYXRlIjogIiIsCiAgICAgICAgImVuZGluZ0RhdGUiOiAiIgogICAgfQp9"
    newDatasources.Variables = VariablesArray
    myArray.push(newDatasources)

    newRequest.Datasources = myArray

    const req_data = JSON.stringify(newRequest)

    const options = {
        hostname: 'report.sample.com',
        port: 80,
        path: '/v1/reports',
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Content-Length': req_data.length
        }
      }
      const req = http.request(options, (error, resp, body) => {
        console.log(`statusCode: ${res.statusCode}`)

        resp.on('data', (d) => {
          process.stdout.write(d)
        })
      })

      resp.on('error', (error) => {
        console.error(error)
      })

      req.write(req_data)

      req.end()

      response.send("done")
    });
</code>```

This prints out the received data on my terminal, but how can I go about storing it in a variable and return it as a response to a request? just some background to what i am doing. I am building a report request which is then send to a api via the request which returns me the data in form of the encoded string

答:
It's difficult to tell exactly what you're using to run this.

Use

```<code>res.status(200).send({success: true, data: data})
</code>```

if you're using express.

Body:
I am using the request module to make a request to an API which sends me a Base64 encoded response which is a file.

    app.get("/report", async(request, response) => {
    const newRequest = new mdl.Request
    const newDatasources = new  mdl.Datasources
    const newVariables = new mdl.VariablesType
    const VariablesArray = []
    const myArray = []

    newRequest.Uri = "http://127.0.0.1:8080/listing.docx"
 newRequest.Async = false
    newRequest.OutputFormat = "html"
    newVariables.Name = "Var1"
    newVariables.Type = "text"
    newVariables.Value = "Hello World!"
    VariablesArray.push(newVariables)
    newDatasources.Name = "JSON"
    newDatasources.Type = "JSON"
    newDatasources.Data = "ewogICAgImxpc3RQcmljZSI6ICIkODc5LDAwMCIsCiAAgICAgInB1cmNoQ29udHJhY3REYXRlIjogIiIsCiAgICAgICAgImVuZGluZ0RhdGUiOiAiIgogICAgfQp9"
    newDatasources.Variables = VariablesArray
    myArray.push(newDatasources)

    newRequest.Datasources = myArray

    const req_data = JSON.stringify(newRequest)

    const options = {
        hostname: 'report.sample.com',
        port: 80,
        path: '/v1/reports',
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Content-Length': req_data.length
        }
      }
      const req = http.request(options, (error, resp, body) => {
        console.log(`statusCode: ${res.statusCode}`)

        resp.on('data', (d) => {
          process.stdout.write(d)
        })
      })

      resp.on('error', (error) => {
        console.error(error)
      })

      req.write(req_data)

      req.end()

      response.send("done")
    });

This prints out the received data on my terminal, but how can I go about storing it in a variable and return it as a response to a request? just some background to what i am doing. I am building a report request which is then send to a api via the request which returns me the data in form of the encoded string

Body:
It's difficult to tell exactly what you're using to run this.

Use

res.status(200).send({success: true, data: data})

if you're using express.


问:
VisualStudio Community 2013 prompts to update trial license
I have installed VisualStudio 2013 Community, as per Microsoft documentation VisualStudio 2013 Community is free and will not require any license.

But today I saw a notification on VisualStudio 2013 community IDE prompting me to update the trial license. Is this a bug?

答: I faced the same problem today with Visual Studio Community 2019. The warning disappeared after logout and login again from my Visual Studio account and restart it.


问:
Ansible change all dict key values only by filters
I have an ansible dict like

```<code>ports:
  webui: 7200
  webadmin: 7209
  core_api: 7201
  stock_api: 7204
  import_export: 7207
</code>```

And i want to transform all keys in it, like

```<code>ports:
  staging-webui: 7200
  staging-webadmin: 7209
  staging-core_api: 7201
  staging-stock_api: 7204
  staging-import_export: 7207
</code>```

I do that in 'vars' section, so i can't use 'set_fact' with 'with_items' to iterate over dict. Is it possible to it only by filters?

I found working answer,

```<code>env: staging # comes from outside

regex_env: "\"key\": \"{{ env }}-\\1\""
app_upstreams: "{{ ports | dict2items | map('to_json') | map('regex_replace', '\"key\":\\s\"(.*)\"', lookup('vars', 'regex_env')) | map('from_json') }}"
</code>```

but it looks really ugly, is there more good-looking solution?

答:
For example, the playbook below

- hosts: localhost
  vars:
    env: staging_
    ports:
      webui: 7200
      webadmin: 7209
      core_api: 7201
      stock_api: 7204
      import_export: 7207
    env_ports_keys: "{{ [env]|product(ports.keys()|list)|map('join') }}"
    env_ports_vals: "{{ ports.values()|list }}"
    env_ports: "{{ dict(env_ports_keys|zip(env_ports_vals)) }}"
  tasks:
    - debug:
        var: env_ports
```
<p>gives (abridged)</p>
<pre class="lang-yaml prettyprint-override"><code>  env_ports:
    staging_core_api: 7201
    staging_import_export: 7207
    staging_stock_api: 7204
    staging_webadmin: 7209
    staging_webui: 7200
</code>```

To simplify the code, you can create a custom filter

shell> cat filter_plugins/dict_utils.py
def prefix_key(d, prefix='prefix'):
    temp = {}
    for key in d.keys():
        temp[prefix + key] = d[key]
    return temp

class FilterModule(object):
    ''' utility filters for operating on dictionary '''
    def filters(self):
        return {
            'prefix_key': prefix_key,
        }
```
<p>The playbook below gives the same result</p>
<pre class="lang-yaml prettyprint-override"><code>- hosts: localhost
  vars:
    env: staging_
    ports:
      webui: 7200
      webadmin: 7209
      core_api: 7201
      stock_api: 7204
      import_export: 7207
    env_ports: "{{ ports|prefix_key(prefix=env) }}"
  tasks:
    - debug:
        var: env_ports
</code>```

Body:
I have an ansible dict like

ports:
  webui: 7200
  webadmin: 7209
  core_api: 7201
  stock_api: 7204
  import_export: 7207

And i want to transform all keys in it, like

ports:
  staging-webui: 7200
  staging-webadmin: 7209
  staging-core_api: 7201
  staging-stock_api: 7204
  staging-import_export: 7207

I do that in 'vars' section, so i can't use 'set_fact' with 'with_items' to iterate over dict. Is it possible to it only by filters?

I found working answer,

env: staging # comes from outside

regex_env: "\"key\": \"{{ env }}-\\1\""
app_upstreams: "{{ ports | dict2items | map('to_json') | map('regex_replace', '\"key\":\\s\"(.*)\"', lookup('vars', 'regex_env')) | map('from_json') }}"

but it looks really ugly, is there more good-looking solution?

Body:
For example, the playbook below

- hosts: localhost
  vars:
    env: staging_
    ports:
      webui: 7200
      webadmin: 7209
      core_api: 7201
      stock_api: 7204
      import_export: 7207
    env_ports_keys: "{{ [env]|product(ports.keys()|list)|map('join') }}"
    env_ports_vals: "{{ ports.values()|list }}"
    env_ports: "{{ dict(env_ports_keys|zip(env_ports_vals)) }}"
  tasks:
    - debug:
        var: env_ports

gives (abridged)

  env_ports:
    staging_core_api: 7201
    staging_import_export: 7207
    staging_stock_api: 7204
    staging_webadmin: 7209
    staging_webui: 7200

To simplify the code, you can create a custom filter

shell> cat filter_plugins/dict_utils.py
def prefix_key(d, prefix='prefix'):
    temp = {}
    for key in d.keys():
        temp[prefix + key] = d[key]
    return temp

class FilterModule(object):
    ''' utility filters for operating on dictionary '''
    def filters(self):
        return {
            'prefix_key': prefix_key,
        }

The playbook below gives the same result

- hosts: localhost
  vars:
    env: staging_
    ports:
      webui: 7200
      webadmin: 7209
      core_api: 7201
      stock_api: 7204
      import_export: 7207
    env_ports: "{{ ports|prefix_key(prefix=env) }}"
  tasks:
    - debug:
        var: env_ports


问:
Unable to iterate through list - Openpyxl
I am unable to iterate through rows of data (that I saved into a list).

Below is the sample code

```<code>Timelist = []
for row_cells in sheetname.iter_rows(min_col=1,max_col=6,min_row=2):
             Timelist = row_cells[1].value

for x in Timelist:
    print(x)
</code>```

I want to get iterate through row values for that column (in this case column 1)

答:
You probably want to append the values to your list Timelist inside the for loop instead of assigning, to be able to iterate over it later for printing x

```<code>Timelist = []

for row_cells in sheetname.iter_rows(min_col=1,max_col=6,min_row=2):
    Timelist.append(row_cells[1].value) # <--- append here

for x in Timelist:
    print(x)
</code>```

Body:
I am unable to iterate through rows of data (that I saved into a list).

Below is the sample code

Timelist = []
for row_cells in sheetname.iter_rows(min_col=1,max_col=6,min_row=2):
             Timelist = row_cells[1].value

for x in Timelist:
    print(x)

I want to get iterate through row values for that column (in this case column 1)

Body:
You probably want to append the values to your list Timelist inside the for loop instead of assigning, to be able to iterate over it later for printing x

Timelist = []

for row_cells in sheetname.iter_rows(min_col=1,max_col=6,min_row=2):
    Timelist.append(row_cells[1].value) # <--- append here

for x in Timelist:
    print(x)


问:
ld: foo.o:foo.h:6 multiple definition of `bar' foo.h:6: first defined here
I am testing some patches for BOINC client, but I am obtaining error message

```<code>/usr/bin/ld: boinc_client-hostinfo_unix.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: multiple definition of `proxy'; boinc_client-user_idle_time_detection.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: first defined here
</code>```

I used include guards, but I don't know what can be the problem. Here I attached affected files and makefile files.
Thank you

hostinfo_unix.cpp

```<code>#include "linux/user_idle_time_detection.h"
CUT
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
    double user_idle_time;
    double user_pref_idle_time_in_ms;
    //user_idle_time = get_user_idle_time();
    user_pref_idle_time_in_ms = (idle_time_to_run * 60000);
CUT
</code>```

linux/user_idle_time_detection.h

```<code>#ifndef USER_IDLE_TIME_DETECTION_H
#define USER_IDLE_TIME_DETECTION_H
#include <gio/gio.h>
#include "gnome/gnome_dbus_interface.h"

GDBusProxy* proxy = NULL;
GDBusProxy* create_proxy();
double get_user_idle_time();
#endif /* USER_IDLE_TIME_DETECTION_H */
</code>```

linux/user_idle_time_detection.c

```<code>#include <gio/gio.h>
#include "user_idle_time_detection.h"
GDBusProxy* create_proxy()
{
    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                           G_DBUS_PROXY_FLAGS_NONE,
                                           NULL,
                                           GNOME_DBUS_SERVICE,
                                           GNOME_DBUS_PATH_SETTINGS,
                                           GNOME_DBUS_INTERFACE_SETTINGS,
                                           NULL, NULL);
    return proxy;
}

double get_user_idle_time()
{
    guint64 user_idle_time;
    double user_idle_time_double;
    GError* error = NULL;
    GVariant* ret = NULL;
    proxy = create_proxy();

    ret = g_dbus_proxy_call_sync(proxy,
                                  GNOME_DBUS_METHOD_SETTINGS,
                                  NULL,
                                  G_DBUS_CALL_FLAGS_NONE, -1,
                                  NULL, &error);
    if (!ret) {
        g_dbus_error_strip_remote_error (error);
        g_print ("GetIdletime failed: %s\n", error->message);
        g_error_free (error);
        return;
    }

    g_variant_get(ret, "(t)", &user_idle_time);
    user_idle_time_double = (double)user_idle_time;
    g_variant_unref (ret);
    return user_idle_time_double;
}
</code>```

linux/gnome/gnome_dbus_interface.h

```<code>#ifndef GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_INTERFACE_H

#define GNOME_DBUS_SERVICE "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_PATH_SETTINGS "/org/gnome/Mutter/IdleMonitor/Core"
#define GNOME_DBUS_INTERFACE_SETTINGS "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_METHOD_SETTINGS "GetIdletime"
#endif /* GNOME_DBUS_INTERFACE_H */
</code>```

Makefile.am

```<code>## -*- mode: makefile; tab-width: 4 -*-
## $Id$

include $(top_srcdir)/Makefile.incl

if ENABLE_CLIENT_RELEASE
  AM_LDFLAGS += -static-libtool-libs
## for an entirely statically linked library, you may want to try
## -all-static instead.  There's a good chance it won't work properly,
## so we'll use the safer "-static-libtool-libs" by default.
else
if DYNAMIC_CLIENT
## if libtool starts to need flags for dynamic linking, add them here
else
  AM_LDFLAGS += -static
endif
endif ## ENABLE_CLIENT_RELEASE

LIBS += $(CLIENTLIBS)

if OS_DARWIN
   LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa -framework CoreServices
endif

bin_PROGRAMS = boinc_client boinccmd
if !OS_WIN32
bin_PROGRAMS += switcher
endif

boinccmd_SOURCES = boinc_cmd.cpp
boinccmd_DEPENDENCIES = $(LIBBOINC)
boinccmd_CPPFLAGS = $(AM_CPPFLAGS)
boinccmd_LDFLAGS = $(AM_LDFLAGS) -L$(top_srcdir)/lib
boinccmd_LDADD = $(LIBBOINC) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)

boinc_client_SOURCES = \
    acct_mgr.cpp \
    acct_setup.cpp \
    app.cpp \
    app_config.cpp \
    app_control.cpp \
    app_start.cpp \
    async_file.cpp \
    check_state.cpp \
    client_msgs.cpp \
    client_state.cpp \
    client_types.cpp \
    coproc_sched.cpp \
    cpu_sched.cpp \
    cs_account.cpp \
    cs_apps.cpp \
    cs_benchmark.cpp \
    cs_cmdline.cpp \
    cs_files.cpp \
    cs_notice.cpp \
    cs_platforms.cpp \
    cs_prefs.cpp \
    cs_proxy.cpp \
    cs_scheduler.cpp \
    cs_statefile.cpp \
    cs_trickle.cpp \
    current_version.cpp \
    dhrystone.cpp \
    dhrystone2.cpp \
    file_names.cpp \
    file_xfer.cpp \
    gpu_amd.cpp \
    gpu_detect.cpp \
    gpu_intel.cpp \
    gpu_nvidia.cpp \
    gpu_opencl.cpp \
    gui_http.cpp \
    gui_rpc_server.cpp \
    gui_rpc_server_ops.cpp \
    hostinfo_linux.cpp \
    hostinfo_network.cpp \
    http_curl.cpp \
    log_flags.cpp \
    mac_address.cpp \
    main.cpp \
    net_stats.cpp \
    pers_file_xfer.cpp \
    project.cpp \
    project_list.cpp \
    result.cpp \
    rr_sim.cpp \
    sandbox.cpp \
    scheduler_op.cpp \
    thread.cpp \
    time_stats.cpp \
    whetstone.cpp \
    work_fetch.cpp \
    linux/user_idle_time_detection.c

boinc_client_DEPENDENCIES = $(LIBBOINC)
boinc_client_CPPFLAGS = $(AM_CPPFLAGS) $(GIO_CFLAGS) $(GLIB_CFLAGS)
boinc_client_CXXFLAGS = $(AM_CXXFLAGS) $(SSL_CXXFLAGS)
boinc_client_LDFLAGS = $(AM_LDFLAGS) $(SSL_LDFLAGS) $(GIO_LIBS) $(GLIB_LIBS)  -L$(top_srcdir)/lib
if OS_WIN32
boinc_client_CXXFLAGS += -I$(top_srcdir)/coprocs/NVIDIA/include
boinc_client_SOURCES += hostinfo_win.cpp \
    hostinfo_wsl.cpp \
    sysmon_win.cpp \
    win/boinc_cli.rc \
    win/res/boinc.ico
else
if OS_DARWIN
boinc_client_LDFLAGS += -Wl,-flat_namespace,-undefined,dynamic_lookup
else
boinc_client_SOURCES += hostinfo_unix.cpp
endif
endif
boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)

boinc_clientdir = $(bindir)

if OS_ARM_LINUX
boinc_client_LDADD += libwhetneon.a libwhetvfp.a
noinst_LIBRARIES = libwhetneon.a libwhetvfp.a
libwhetneon_a_SOURCES = whetstone.cpp
libwhetneon_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon

libwhetvfp_a_SOURCES = whetstone.cpp
libwhetvfp_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_VFP -mfloat-abi=softfp -mfpu=vfp
endif

switcher_SOURCES = switcher.cpp
switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
switcher_LDADD = $(LIBBOINC)

## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly.  The next two rules do that...
all-local: boinc$(EXEEXT)

boinc$(EXEEXT): boinc_client$(EXEEXT)
    rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT)
    $(LN) boinc_client$(EXEEXT) boinc$(EXEEXT)
    if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi

install-exec-hook:
    rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
    $(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)

## these source files need to be specified because no rule uses them.

EXTRA_DIST = *.h \
    mac \
    translation \
    win
</code>```

Makefile.curl.am

```<code>## -*- mode: make; tab-width: 4 -*-
## $Id$

include $(top_srcdir)/Makefile.incl

# (for a while we used "-static -static-libgcc" on linux, but this is obsolete
# now)
#STATIC_FLAGS=@STATIC_FLAGS@

client-bin: @CLIENT_BIN_FILENAME@

LIBS += @CLIENTLIBS@

bin_PROGRAMS = boinc_client

EXTRA_PROGRAMS = cpu_benchmark

boinc_client_SOURCES = \
    acct_mgr.cpp \
    acct_setup.cpp \
    app.cpp \
    app_control.cpp \
    app_graphics.cpp \
    app_start.cpp \
    check_state.cpp \
    client_msgs.cpp \
    client_state.cpp \
    client_types.cpp \
    cs_account.cpp \
    cs_apps.cpp \
    cs_benchmark.cpp \
    cs_cmdline.cpp \
    cs_data.cpp \
    cs_files.cpp \
    cs_prefs.cpp \
    cs_scheduler.cpp \
    cs_statefile.cpp \
    cs_trickle.cpp \
    dhrystone.cpp \
    dhrystone2.cpp \
    file_names.cpp \
    file_xfer.cpp \
    gui_http.cpp \
    gui_rpc_server.cpp \
    gui_rpc_server_ops.cpp \
    hostinfo_linux.cpp \
    hostinfo_network.cpp \
    hostinfo_unix.cpp \
    http_curl.cpp \
    log_flags.cpp \
    main.cpp \
    net_stats.cpp \
    net_xfer_curl.cpp \
    pers_file_xfer.cpp \
    scheduler_op.cpp \
    time_stats.cpp \
    whetstone.cpp \
    linux/user_idle_time_detection.c

boinc_client_DEPENDENCIES = $(LIBRSA)
boinc_client_CPPFLAGS = -D_USE_CURL -I../../curl-7.14.0/include -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_LDFLAGS = -static-libgcc
boinc_client_LDADD = -L/usr/local/ssl/lib -lssl -L../../curl-7.14.0/lib -lcurl -L../lib -lboinc $(RSA_LIBS) $(PTHREAD_LIBS)
#boinc_client_LDFLAGS = $(STATIC_FLAGS)

# the following don't do anything
cpu_benchmark_SOURCES = whetstone.cpp dhrystone.cpp
cpu_benchmark_CFLAGS = -O3 $(AM_CFLAGS)

all-local: client-bin

# make a hard link to the client name.
@CLIENT_BIN_FILENAME@: boinc_client
    rm -f $@
    @LN@ $? $@
    @STRIP@ $@

## these source files need to be specified because no rule uses them.

EXTRA_DIST = *.h \
    mac \
    translation \
    win

clean-local:
    rm -f @CLIENT_BIN_FILENAME@
</code>```

configure.ac
Cannot insert it here due Stackoverflow characters limit.

答: If you intend to use proxy as a global variable across multiple translation units it should be declared with extern.

Body:
I am testing some patches for BOINC client, but I am obtaining error message

/usr/bin/ld: boinc_client-hostinfo_unix.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: multiple definition of `proxy'; boinc_client-user_idle_time_detection.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: first defined here

I used include guards, but I don't know what can be the problem. Here I attached affected files and makefile files.
Thank you

hostinfo_unix.cpp

#include "linux/user_idle_time_detection.h"
CUT
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
    double user_idle_time;
    double user_pref_idle_time_in_ms;
    //user_idle_time = get_user_idle_time();
    user_pref_idle_time_in_ms = (idle_time_to_run * 60000);
CUT

linux/user_idle_time_detection.h

#ifndef USER_IDLE_TIME_DETECTION_H
#define USER_IDLE_TIME_DETECTION_H
#include <gio/gio.h>
#include "gnome/gnome_dbus_interface.h"

GDBusProxy* proxy = NULL;
GDBusProxy* create_proxy();
double get_user_idle_time();
#endif /* USER_IDLE_TIME_DETECTION_H */

linux/user_idle_time_detection.c

#include <gio/gio.h>
#include "user_idle_time_detection.h"
GDBusProxy* create_proxy()
{
    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                           G_DBUS_PROXY_FLAGS_NONE,
                                           NULL,
                                           GNOME_DBUS_SERVICE,
                                           GNOME_DBUS_PATH_SETTINGS,
                                           GNOME_DBUS_INTERFACE_SETTINGS,
                                           NULL, NULL);
    return proxy;
}

double get_user_idle_time()
{
    guint64 user_idle_time;
    double user_idle_time_double;
    GError* error = NULL;
    GVariant* ret = NULL;
    proxy = create_proxy();

    ret = g_dbus_proxy_call_sync(proxy,
                                  GNOME_DBUS_METHOD_SETTINGS,
                                  NULL,
                                  G_DBUS_CALL_FLAGS_NONE, -1,
                                  NULL, &error);
    if (!ret) {
        g_dbus_error_strip_remote_error (error);
        g_print ("GetIdletime failed: %s\n", error->message);
        g_error_free (error);
        return;
    }

    g_variant_get(ret, "(t)", &user_idle_time);
    user_idle_time_double = (double)user_idle_time;
    g_variant_unref (ret);
    return user_idle_time_double;
}

linux/gnome/gnome_dbus_interface.h

#ifndef GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_INTERFACE_H

#define GNOME_DBUS_SERVICE "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_PATH_SETTINGS "/org/gnome/Mutter/IdleMonitor/Core"
#define GNOME_DBUS_INTERFACE_SETTINGS "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_METHOD_SETTINGS "GetIdletime"
#endif /* GNOME_DBUS_INTERFACE_H */

Makefile.am

## -*- mode: makefile; tab-width: 4 -*-
## $Id$

include $(top_srcdir)/Makefile.incl

if ENABLE_CLIENT_RELEASE
  AM_LDFLAGS += -static-libtool-libs
## for an entirely statically linked library, you may want to try
## -all-static instead.  There's a good chance it won't work properly,
## so we'll use the safer "-static-libtool-libs" by default.
else
if DYNAMIC_CLIENT
## if libtool starts to need flags for dynamic linking, add them here
else
  AM_LDFLAGS += -static
endif
endif ## ENABLE_CLIENT_RELEASE

LIBS += $(CLIENTLIBS)

if OS_DARWIN
   LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa -framework CoreServices
endif

bin_PROGRAMS = boinc_client boinccmd
if !OS_WIN32
bin_PROGRAMS += switcher
endif

boinccmd_SOURCES = boinc_cmd.cpp
boinccmd_DEPENDENCIES = $(LIBBOINC)
boinccmd_CPPFLAGS = $(AM_CPPFLAGS)
boinccmd_LDFLAGS = $(AM_LDFLAGS) -L$(top_srcdir)/lib
boinccmd_LDADD = $(LIBBOINC) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)

boinc_client_SOURCES = \
    acct_mgr.cpp \
    acct_setup.cpp \
    app.cpp \
    app_config.cpp \
    app_control.cpp \
    app_start.cpp \
    async_file.cpp \
    check_state.cpp \
    client_msgs.cpp \
    client_state.cpp \
    client_types.cpp \
    coproc_sched.cpp \
    cpu_sched.cpp \
    cs_account.cpp \
    cs_apps.cpp \
    cs_benchmark.cpp \
    cs_cmdline.cpp \
    cs_files.cpp \
    cs_notice.cpp \
    cs_platforms.cpp \
    cs_prefs.cpp \
    cs_proxy.cpp \
    cs_scheduler.cpp \
    cs_statefile.cpp \
    cs_trickle.cpp \
    current_version.cpp \
    dhrystone.cpp \
    dhrystone2.cpp \
    file_names.cpp \
    file_xfer.cpp \
    gpu_amd.cpp \
    gpu_detect.cpp \
    gpu_intel.cpp \
    gpu_nvidia.cpp \
    gpu_opencl.cpp \
    gui_http.cpp \
    gui_rpc_server.cpp \
    gui_rpc_server_ops.cpp \
    hostinfo_linux.cpp \
    hostinfo_network.cpp \
    http_curl.cpp \
    log_flags.cpp \
    mac_address.cpp \
    main.cpp \
    net_stats.cpp \
    pers_file_xfer.cpp \
    project.cpp \
    project_list.cpp \
    result.cpp \
    rr_sim.cpp \
    sandbox.cpp \
    scheduler_op.cpp \
    thread.cpp \
    time_stats.cpp \
    whetstone.cpp \
    work_fetch.cpp \
    linux/user_idle_time_detection.c

boinc_client_DEPENDENCIES = $(LIBBOINC)
boinc_client_CPPFLAGS = $(AM_CPPFLAGS) $(GIO_CFLAGS) $(GLIB_CFLAGS)
boinc_client_CXXFLAGS = $(AM_CXXFLAGS) $(SSL_CXXFLAGS)
boinc_client_LDFLAGS = $(AM_LDFLAGS) $(SSL_LDFLAGS) $(GIO_LIBS) $(GLIB_LIBS)  -L$(top_srcdir)/lib
if OS_WIN32
boinc_client_CXXFLAGS += -I$(top_srcdir)/coprocs/NVIDIA/include
boinc_client_SOURCES += hostinfo_win.cpp \
    hostinfo_wsl.cpp \
    sysmon_win.cpp \
    win/boinc_cli.rc \
    win/res/boinc.ico
else
if OS_DARWIN
boinc_client_LDFLAGS += -Wl,-flat_namespace,-undefined,dynamic_lookup
else
boinc_client_SOURCES += hostinfo_unix.cpp
endif
endif
boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)

boinc_clientdir = $(bindir)

if OS_ARM_LINUX
boinc_client_LDADD += libwhetneon.a libwhetvfp.a
noinst_LIBRARIES = libwhetneon.a libwhetvfp.a
libwhetneon_a_SOURCES = whetstone.cpp
libwhetneon_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon

libwhetvfp_a_SOURCES = whetstone.cpp
libwhetvfp_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_VFP -mfloat-abi=softfp -mfpu=vfp
endif

switcher_SOURCES = switcher.cpp
switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
switcher_LDADD = $(LIBBOINC)

## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly.  The next two rules do that...
all-local: boinc$(EXEEXT)

boinc$(EXEEXT): boinc_client$(EXEEXT)
    rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT)
    $(LN) boinc_client$(EXEEXT) boinc$(EXEEXT)
    if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi

install-exec-hook:
    rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
    $(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)

## these source files need to be specified because no rule uses them.

EXTRA_DIST = *.h \
    mac \
    translation \
    win

Makefile.curl.am

## -*- mode: make; tab-width: 4 -*-
## $Id$

include $(top_srcdir)/Makefile.incl

# (for a while we used "-static -static-libgcc" on linux, but this is obsolete
# now)
#STATIC_FLAGS=@STATIC_FLAGS@

client-bin: @CLIENT_BIN_FILENAME@

LIBS += @CLIENTLIBS@

bin_PROGRAMS = boinc_client

EXTRA_PROGRAMS = cpu_benchmark

boinc_client_SOURCES = \
    acct_mgr.cpp \
    acct_setup.cpp \
    app.cpp \
    app_control.cpp \
    app_graphics.cpp \
    app_start.cpp \
    check_state.cpp \
    client_msgs.cpp \
    client_state.cpp \
    client_types.cpp \
    cs_account.cpp \
    cs_apps.cpp \
    cs_benchmark.cpp \
    cs_cmdline.cpp \
    cs_data.cpp \
    cs_files.cpp \
    cs_prefs.cpp \
    cs_scheduler.cpp \
    cs_statefile.cpp \
    cs_trickle.cpp \
    dhrystone.cpp \
    dhrystone2.cpp \
    file_names.cpp \
    file_xfer.cpp \
    gui_http.cpp \
    gui_rpc_server.cpp \
    gui_rpc_server_ops.cpp \
    hostinfo_linux.cpp \
    hostinfo_network.cpp \
    hostinfo_unix.cpp \
    http_curl.cpp \
    log_flags.cpp \
    main.cpp \
    net_stats.cpp \
    net_xfer_curl.cpp \
    pers_file_xfer.cpp \
    scheduler_op.cpp \
    time_stats.cpp \
    whetstone.cpp \
    linux/user_idle_time_detection.c

boinc_client_DEPENDENCIES = $(LIBRSA)
boinc_client_CPPFLAGS = -D_USE_CURL -I../../curl-7.14.0/include -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_LDFLAGS = -static-libgcc
boinc_client_LDADD = -L/usr/local/ssl/lib -lssl -L../../curl-7.14.0/lib -lcurl -L../lib -lboinc $(RSA_LIBS) $(PTHREAD_LIBS)
#boinc_client_LDFLAGS = $(STATIC_FLAGS)

# the following don't do anything
cpu_benchmark_SOURCES = whetstone.cpp dhrystone.cpp
cpu_benchmark_CFLAGS = -O3 $(AM_CFLAGS)

all-local: client-bin

# make a hard link to the client name.
@CLIENT_BIN_FILENAME@: boinc_client
    rm -f $@
    @LN@ $? $@
    @STRIP@ $@

## these source files need to be specified because no rule uses them.

EXTRA_DIST = *.h \
    mac \
    translation \
    win

clean-local:
    rm -f @CLIENT_BIN_FILENAME@

configure.ac
Cannot insert it here due Stackoverflow characters limit.


问:
Invalid syntax ON CONFLICT when inserting to database
Trying to insert data to a new empty table with unique constraints.  When I remove the ON CONFLICT statement the code errors out immediately with a violation of the unique constraint in the first insert try even though the table is empty.  When I remove the unique constraints from the table, the data is duplicated when I rerun the code.

I would like the insert to verify if the row exists and do nothing and if it does not exist, to make a new entry.  I'm running postgres 11.3 on Mac OSX.  Any help appreciated.

```<code>psycopg2.extras.execute_values(cur,
    "insert  into ferc_hots (html,link) values %s",
    values)
on conflict (html,link) do nothing

con.commit()
print("Records inserted successfully")
con.close()
</code>```

答:
Your fix should really be simple since you just have the on conflict line in the wrong place.

```<code>psycopg2.extras.execute_values(cur,
    """insert  into ferc_hots (html,link) values %s
       on conflict (html,link) do nothing""", # Moved to inside SQL
    values)

con.commit()
print("Records inserted successfully")
con.close()
</code>```

Body:
Trying to insert data to a new empty table with unique constraints.  When I remove the ON CONFLICT statement the code errors out immediately with a violation of the unique constraint in the first insert try even though the table is empty.  When I remove the unique constraints from the table, the data is duplicated when I rerun the code.

I would like the insert to verify if the row exists and do nothing and if it does not exist, to make a new entry.  I'm running postgres 11.3 on Mac OSX.  Any help appreciated.

psycopg2.extras.execute_values(cur,
    "insert  into ferc_hots (html,link) values %s",
    values)
on conflict (html,link) do nothing

con.commit()
print("Records inserted successfully")
con.close()

Body:
Your fix should really be simple since you just have the on conflict line in the wrong place.

psycopg2.extras.execute_values(cur,
    """insert  into ferc_hots (html,link) values %s
       on conflict (html,link) do nothing""", # Moved to inside SQL
    values)

con.commit()
print("Records inserted successfully")
con.close()


问:
An error occurred when attempting to open certificate list, the error was: Automation server can't create object
I'm trying to fill up a form from here . Upon selecting Natural Person from the drop-down menu, a form appears with a button Add Digital Signature. Whenever I click on this button, it gives me this error:

```<code>An error occurred when attempting to open certificate list, the error was:
Automation server can't create object
</code>```

I've tried enabling the Initialize and Script Activex controls not marked as safe for scripting feature from internet option but the same error occurred.
I've tried different versions of Internet Explorer starting from version 6. Can anyone help me ?

答:
1)Download capicom_dc_sdk.msi from
https://www.microsoft.com/en-us/download/details.aspx?id=25281
and install.

2)Locate capicom.dll "e.g. C:\Program Files (x86)\Microsoft CAPICOM 2.1.0.2 SDK\Lib\X86\capicom.dll"

2)Open command prompt with administrator privilege, change directory to directory containing capicom.dll and fire below command
regsvr32 capicom.dll

Body:
I'm trying to fill up a form from here . Upon selecting Natural Person from the drop-down menu, a form appears with a button Add Digital Signature. Whenever I click on this button, it gives me this error:

An error occurred when attempting to open certificate list, the error was:
Automation server can't create object

I've tried enabling the Initialize and Script Activex controls not marked as safe for scripting feature from internet option but the same error occurred.
I've tried different versions of Internet Explorer starting from version 6. Can anyone help me ?