internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mytardis/mytardis

Issue:
dynamic SFTP settings page password text incorrect if SITE_TITLE not set in settings.py 
SITE_TITLE set to None in default_settings.py by default, which prevents the default template value for {{ site_name }} to be set to 'MyTardis'. As a result, the password information reads "Your None password" instead of "Your MyTardis password".
![screen shot 2016-01-07 at 4 27 10 pm](https://cloud.githubusercontent.com/assets/6635497/12162847/8a3fd19e-b55b-11e5-9483-7ff220e9a401.png)

default_settings.py: https://github.com/mytardis/mytardis/blob/develop/tardis/default_settings.py#L109
sftp view fn: https://github.com/mytardis/mytardis/blob/develop/tardis/tardis_portal/views/pages.py#L622



Discussion:

Resolving patch:
diff --git a/tardis/default_settings.py b/tardis/default_settings.py
--- a/tardis/default_settings.py
+++ b/tardis/default_settings.py
@@ -106,7 +106,7 @@
 address in production.
 '''
 
-SITE_TITLE = None
+SITE_TITLE = 'MyTardis'
 '''
 customise the title of your site
 '''


Test patch:
Repository: mytardis/mytardis

Issue:
Accessing `/help` URL results in 500 error because `user_guide` template not longer exists
`user_guide` template was remove during docs restructure #977, but url wasn't removed from urls.py.


Discussion:

Resolving patch:
diff --git a/tardis/urls.py b/tardis/urls.py
--- a/tardis/urls.py
+++ b/tardis/urls.py
@@ -68,7 +68,6 @@
     url(r'^public_data/', 'public_data', name='public_data'),
     (r'^about/$', 'about'),
     (r'^stats/$', 'stats'),
-    (r'^help/$', 'user_guide'),
     url(r'^sftp_access/cyberduck/connection.png$',
         'cybderduck_connection_window', name='cyberduck_connection_window'),
     url(r'^sftp_access/$', 'sftp_access', name='sftp_access'),


Test patch:
Repository: mytardis/mytardis

Issue:
/search/parameter_field_list/ failures with Unicode first/last names in Users table
This can occur:
```
Internal Server Error: /search/parameter_field_list/
Traceback (most recent call last):
  File "/home/mytardis/virtualenvs/mytardis/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/mytardis/mytardis/tardis/search/views.py", line 282, in retrieve_field_list
    fieldList = '+'.join([str(fn) for fn in auto_list])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 8: ordinal not in range(128)
```

if there's a user with a non-ASCII character in their first or last name.  The relevant code in tardis/search/views.py is:

```
usernames = [u.first_name + ' ' + u.last_name + ':username' for u in users]
...
auto_list = usernames + searchableFields
fieldList = '+'.join([str(fn) for fn in auto_list])
```



Discussion:

Resolving patch:
diff --git a/tardis/search/views.py b/tardis/search/views.py
--- a/tardis/search/views.py
+++ b/tardis/search/views.py
@@ -276,7 +276,11 @@ def retrieve_field_list(request):
 
     users = User.objects.all()
 
-    usernames = [u.first_name + ' ' + u.last_name + ':username' for u in users]
+    usernames = [
+        u.first_name.encode('utf-8') +
+        ' ' +
+        u.last_name.encode('utf-8') +
+        ':username' for u in users]
 
     # Collect all of the indexed (searchable) fields, except
     # for the main search document ('text')


Test patch:
Repository: mytardis/mytardis

Issue:
"()" is added to "Author" line every time an experiment is edited.
Every time an experiment is edited, for some reason "()" is added to the end of the Author field. So if I edit 3 times three "()" will be added. Its a minor annoyance since the "()" can just be deleted.

This is bug is present on current develop branch.



Discussion:
+1 - I encountered this bug today while demonstrating MyTardis to a new user.


Resolving patch:
diff --git a/tardis/tardis_portal/forms.py b/tardis/tardis_portal/forms.py
--- a/tardis/tardis_portal/forms.py
+++ b/tardis/tardis_portal/forms.py
@@ -413,9 +413,11 @@ def __init__(self, data=None, files=None, auto_id='%s', prefix=None,
             field.widget.attrs['class'] = "span8"
 
     def _format_author(self, author):
-        author_contacts = [author.email, author.url]
-        return "%s (%s)" % (author.author,
-                            ', '.join([c for c in author_contacts if c]))
+        if author.email or author.url:
+            author_contacts = [author.email, author.url]
+            return "%s (%s)" % (author.author,
+                                ', '.join([c for c in author_contacts if c]))
+        return author.author
 
     def _parse_authors(self, data):
         """


Test patch:
Repository: mytardis/mytardis

Issue:
Downloading a TAR including unverified files leads to "Truncated tar archive" error
Attempting to download a TAR archive of a dataset or experiment containing unverified files leads to a "Truncated tar archive" error when attempting to open the TAR archive (after downloading).

The TAR file header indicates that all of the dataset's (or experiment's) files will be included, but only the verified files are included, hence the "Truncated tar archive" error.


Discussion:

Resolving patch:
diff --git a/tardis/tardis_portal/download.py b/tardis/tardis_portal/download.py
--- a/tardis/tardis_portal/download.py
+++ b/tardis/tardis_portal/download.py
@@ -37,6 +37,7 @@
 from tardis.analytics.tracker import IteratorTracker
 from .models import Dataset
 from .models import DataFile
+from .models import DataFileObject
 from .models import Experiment
 from .auth.decorators import has_datafile_download_access
 from .auth.decorators import experiment_download_required
@@ -426,8 +427,10 @@ def streaming_download_experiment(request, experiment_id, comptype='tgz',
     rootdir = get_filesystem_safe_experiment_name(experiment)
     filename = '%s-complete.tar' % rootdir
 
-    datafiles = DataFile.objects.filter(
-        dataset__experiments__id=experiment_id)
+    df_ids = DataFileObject.objects.filter(
+        datafile__dataset__experiments__id=experiment_id, verified=True) \
+                .values('datafile_id').distinct()
+    datafiles = DataFile.objects.filter(id__in=df_ids)
     return _streaming_downloader(request, datafiles, rootdir, filename,
                                  comptype, organization)
 
@@ -439,7 +442,10 @@ def streaming_download_dataset(request, dataset_id, comptype='tgz',
     rootdir = get_filesystem_safe_dataset_name(dataset)
     filename = '%s-complete.tar' % rootdir
 
-    datafiles = DataFile.objects.filter(dataset=dataset)
+    df_ids = DataFileObject.objects.filter(
+        datafile__dataset=dataset, verified=True) \
+        .values('datafile_id').distinct()
+    datafiles = DataFile.objects.filter(id__in=df_ids)
     return _streaming_downloader(request, datafiles, rootdir, filename,
                                  comptype, organization)
 


Test patch:
Repository: mytardis/mytardis

Issue:
With COMPUTE_SHA512 False, verify should not attempt to match sha512 sums
Setting COMPUTE_SHA512 to False in settings.py means that MyTardis won't compute sha512 sums when verifying files, so verification will be quicker.  However, if you have old DataFile records for which sha512 sums were already computed, then setting their DataFileObject's verified status to False and attempted to reverify will fail unless you set the DataFile's sha512sum field to an empty string first.

dfo.verify shouldn't attempt to match sha512 sums if the COMPUTE_SHA512 setting is False.


Discussion:

Resolving patch:
diff --git a/tardis/tardis_portal/models/datafile.py b/tardis/tardis_portal/models/datafile.py
--- a/tardis/tardis_portal/models/datafile.py
+++ b/tardis/tardis_portal/models/datafile.py
@@ -684,7 +684,13 @@ def move_file(self, dest_box=None):
         return copy
 
     def verify(self, add_checksums=True, add_size=True):  # too complex # noqa
-        comparisons = ['size', 'md5sum', 'sha512sum']
+        compute_md5 = getattr(settings, 'COMPUTE_MD5', True)
+        compute_sha512 = getattr(settings, 'COMPUTE_SHA512', True)
+        comparisons = ['size']
+        if compute_md5:
+            comparisons.append('md5sum')
+        if compute_sha512:
+            comparisons.append('sha512sum')
 
         df = self.datafile
         database = {comp_type: getattr(df, comp_type)
@@ -708,8 +714,6 @@ def verify(self, add_checksums=True, add_size=True):  # too complex # noqa
                 if add_size:
                     database_update['size'] = actual['size']
             if same_values.get('size', True):
-                compute_md5 = getattr(settings, 'COMPUTE_MD5', True)
-                compute_sha512 = getattr(settings, 'COMPUTE_SHA512', True)
                 actual.update(compute_checksums(
                     self.file_object,
                     compute_md5=compute_md5,


Test patch:
Repository: mytardis/mytardis

Issue:
NPM_FILE_PATTERNS - collectstatic failing on Windows
MyTardis currently uses `django-npm` to collect static content which has been npm installed into the `node_modules/` folder.

Because we don't necessarily want to copy everything from `node_modules/` when running `collectstatic`, MyTardis uses django-npm's `NPM_FILE_PATTERNS` setting in `tardis/default_settings/static_files.py`

See: https://github.com/kevin1024/django-npm#configuration

It can be used like this:

```
NPM_FILE_PATTERNS = {
    'jquery': ['*'],
    'jquery-migrate': ['*'],
}
```

to copy everything within `node_modules/jquery/` and everything within `node_modules/jquery-migrate/` into the static folder written to by `collectstatic`.

If you only want `collectstatic` to copy a subset of the files in the node_modules folder, `django-npm` provides the ability to use glob patterns like this:

```
NPM_FILE_PATTERNS = {
    'bootstrap': ['dist/*'],
    'font-awesome': ['css/*', 'fonts/*'],
}
```

However, these glob patterns don't seem to work on Windows, i.e. nothing is copied from the `node_modules` folders which have glob patterns more complex than `['*']`, see: https://github.com/kevin1024/django-npm/issues/15

A workaround (when running MyTardis's `collectstatic` on Windows) is to redefine `NPM_FILE_PATTERNS` in your `tardis/settings.py`, and just use the `['*']` pattern for every node module you want to be copied by `collectstatic`.


Discussion:

Resolving patch:
diff --git a/tardis/default_settings/static_files.py b/tardis/default_settings/static_files.py
--- a/tardis/default_settings/static_files.py
+++ b/tardis/default_settings/static_files.py
@@ -32,16 +32,16 @@
     'backbone': ['*'],
     'backbone-forms': ['*'],
     'blueimp-file-upload': ['*'],
-    'bootstrap': ['dist/*'],
+    'bootstrap': ['*'],
     'bootstrap-3-typeahead': ['*'],
     'clipboard': ['*'],
-    'font-awesome': ['css/*', 'fonts/*'],
+    'font-awesome': ['*'],
     'jquery': ['*'],
     'jquery-migrate': ['*'],
     'jquery-ui-dist': ['jquery-ui.min.js'],
     'mustache': ['mustache.min.js'],
     'ng-dialog': ['*'],
-    'sprintf-js': ['dist/*'],
+    'sprintf-js': ['*'],
     'underscore': ['*'],
-    'underscore.string': ['dist/*']
+    'underscore.string': ['*']
 }


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
slack 404
I'm getting the same issue as was reported here: https://github.com/ansible/ansible/issues/8669

Error output I'm getting is:

```
failed: [test-domain.com -> 127.0.0.1] => {"failed": true}
msg:  failed to send payload={"username": "toby", "text": "stage update has successfully completed", "link_names": 1, "channel": "#deploys", "icon_url": "http://www.ansible.com/favicon.ico"} to https://pixelfusion.slack.com/services/hooks/incoming-webhook?token=[obscured]: HTTP Error 404: Not Found
```



Discussion:

Resolving patch:
diff --git a/notification/slack.py b/notification/slack.py
--- a/notification/slack.py
+++ b/notification/slack.py
@@ -105,8 +105,7 @@
 
 """
 
-
-SLACK_INCOMING_WEBHOOK = 'https://%s/services/hooks/incoming-webhook?token=%s'
+SLACK_INCOMING_WEBHOOK = 'https://hooks.slack.com/services/%s'
 
 def build_payload_for_slack(module, text, channel, username, icon_url, icon_emoji, link_names, parse):
     payload = dict(text=text)
@@ -128,11 +127,11 @@ def build_payload_for_slack(module, text, channel, username, icon_url, icon_emoj
     return payload
 
 def do_notify_slack(module, domain, token, payload):
-    slack_incoming_webhook = SLACK_INCOMING_WEBHOOK % (domain, token)
+    slack_incoming_webhook = SLACK_INCOMING_WEBHOOK % (token)
 
     response, info = fetch_url(module, slack_incoming_webhook, data=payload)
     if info['status'] != 200:
-        obscured_incoming_webhook = SLACK_INCOMING_WEBHOOK % (domain, '[obscured]')
+        obscured_incoming_webhook = SLACK_INCOMING_WEBHOOK % ('[obscured]')
         module.fail_json(msg=" failed to send %s to %s: %s" % (payload, obscured_incoming_webhook, info['msg']))
 
 def main():
@@ -170,4 +169,4 @@ def main():
 # import module snippets
 from ansible.module_utils.basic import *
 from ansible.module_utils.urls import *
-main()
\ No newline at end of file
+main()


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
The pkgutil provider reports state: present when a package is not in the catalog
When I try to install a non-existing package with something like

```
# ansible unstable9s -m pkgutil -a "name=CSWlibpsl-dev state=present"
```

The result is success and the state "present" is reported:

```
unstable9s | success >> {
    "changed": true, 
    "name": "CSWlibpsl-dev", 
    "state": "present", 
    "stderr": "Package CSWlibpsl-dev not in catalog. Exiting.\n", 
    "stdout": "Solving needed dependencies ...\n"
}
```

The package was not installed on the machine and is not installed afterwards:

```
unstable9s% pkginfo -x CSWlibpsl-dev
ERROR: information for "CSWlibpsl-dev" was not found
```



Discussion:

Resolving patch:
diff --git a/packaging/os/pkgutil.py b/packaging/os/pkgutil.py
--- a/packaging/os/pkgutil.py
+++ b/packaging/os/pkgutil.py
@@ -163,9 +163,13 @@ def main():
             out = out[:75]
 
     if rc is None:
+        # pkgutil was not executed because the package was already present/absent
         result['changed'] = False
-    else:
+    elif rc == 0
         result['changed'] = True
+    else
+        result['changed'] = False
+        result['failed'] = True
 
     if out:
         result['stdout'] = out


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
patch module does not support local files
Given the following task:

```
- name: Apply patches
  patch: >
    basedir="/home/user/virtualenv/lib64/python2.7/site-packages/"
    src="patches/some.patch"
    remote_src=False
```

plus an accompanying file in `files/patches/some.patch` in the same role, I get:

```
failed: [remotehost] => {"failed": true}
msg: src patches/some.patch doesn't exist or not readable
```

I ran Ansible through an strace and found it does not even attempt to stat the local file, so this does not look like a typo/configuration error to me.



Discussion:

Resolving patch:
diff --git a/files/patch.py b/files/patch.py
old mode 100644
new mode 100755
--- a/files/patch.py
+++ b/files/patch.py
@@ -43,7 +43,9 @@
     aliases: [ "originalfile" ]
   src:
     description:
-      - Path of the patch file as accepted by the GNU patch tool.
+      - Path of the patch file as accepted by the GNU patch tool. If
+        C(remote_src) is False, the patch source file is looked up from the
+        module's "files" directory.
     required: true
     aliases: [ "patchfile" ]
   remote_src:
@@ -141,8 +143,13 @@ def main():
         p.basedir = path.dirname(p.dest)
 
     patch_bin = module.get_bin_path('patch')
+    if patch_bin is None:
+        module.fail_json(msg="patch command not found")
     patch_func = lambda opts: module.run_command("%s %s" % (patch_bin, ' '.join(opts)))
 
+    # patch need an absolute file name
+    p.src = os.path.abspath(p.src)
+    
     changed = False
     if not is_already_applied(patch_func, p.src, p.basedir, dest_file=p.dest, strip=p.strip):
         try:


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
patch should support expanduser
Right now, if the source contains ~user, we got the error message that the source is not readable.

It should use os.path.expanduser as other file modules.



Discussion:

Resolving patch:
diff --git a/files/patch.py b/files/patch.py
--- a/files/patch.py
+++ b/files/patch.py
@@ -130,6 +130,7 @@ def main():
     # Create type object as namespace for module params
     p = type('Params', (), module.params)
 
+    p.src = os.path.expanduser(p.src)
     if not os.access(p.src, R_OK):
         module.fail_json(msg="src %s doesn't exist or not readable" % (p.src))
 


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
known_hosts module fails on RHEL5 (python 2.4)
##### Issue Type:

Bug Report
##### Ansible Version: ansible 1.9.0.1
##### Environment:

RHEL5
##### Summary:

When running `known_hosts` again RHEL5, it fails because the "delete" argument to `tempfile.NamedTemporaryFile` was added in Python 2.6: https://docs.python.org/2/library/tempfile.html

```
Traceback (most recent call last):
  File "/tmp/ansible-tmp-1429314002.36-240382345137902/known_hosts", line 1835, in ?
    main()
  File "/tmp/ansible-tmp-1429314002.36-240382345137902/known_hosts", line 236, in main
    results = enforce_state(module,module.params)
  File "/tmp/ansible-tmp-1429314002.36-240382345137902/known_hosts", line 102, in enforce_state
    sanity_check(module,host,key,sshkeygen)
  File "/tmp/ansible-tmp-1429314002.36-240382345137902/known_hosts", line 165, in sanity_check
    outf=tempfile.NamedTemporaryFile(delete=False)
TypeError: NamedTemporaryFile() got an unexpected keyword argument 'delete'
```
##### Steps To Reproduce:

Run `known_hosts` module against a RHEL5 target.



Discussion:

Resolving patch:
diff --git a/system/known_hosts.py b/system/known_hosts.py
--- a/system/known_hosts.py
+++ b/system/known_hosts.py
@@ -128,18 +128,23 @@ def enforce_state(module, params):
                 module.fail_json(msg="Failed to read %s: %s" % \
                                      (path,str(e)))
         try:
-            outf=tempfile.NamedTemporaryFile(dir=os.path.dirname(path),
-                                             delete=False)
+            outf=tempfile.NamedTemporaryFile(dir=os.path.dirname(path))
             if inf is not None:
                 for line in inf:
                     outf.write(line)
                 inf.close()
             outf.write(key)
-            outf.close()
+            outf.flush()
             module.atomic_move(outf.name,path)
         except (IOError,OSError),e:
             module.fail_json(msg="Failed to write to file %s: %s" % \
                                  (path,str(e)))
+
+        try:
+            outf.close()
+        except:
+            pass
+
         params['changed'] = True
 
     return params
@@ -162,16 +167,20 @@ def sanity_check(module,host,key,sshkeygen):
     #The approach is to write the key to a temporary file,
     #and then attempt to look up the specified host in that file.
     try:
-        outf=tempfile.NamedTemporaryFile(delete=False)
+        outf=tempfile.NamedTemporaryFile()
         outf.write(key)
-        outf.close()
+        outf.flush()
     except IOError,e:
         module.fail_json(msg="Failed to write to temporary file %s: %s" % \
                              (outf.name,str(e)))
     rc,stdout,stderr=module.run_command([sshkeygen,'-F',host,
                                          '-f',outf.name],
                                         check_rc=True)
-    os.remove(outf.name)
+    try:
+        outf.close()
+    except:
+        pass
+
     if stdout=='': #host not found
         module.fail_json(msg="Host parameter does not match hashed host field in supplied key")
 


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
locale_gen is_present check fails with some locales
##### Issue Type:

Bug Report
##### Ansible Version:

```
ansible 1.9.2
  configured module search path = None
```
##### Ansible Configuration:

No custom config
##### Environment:

Managing OS: OS X 10.10.4
Target OS: Debian Jessie
##### Summary:

`locale_gen` uses the ouput of `locale -a` to test if a given locale is already enabled ([See here](https://github.com/ansible/ansible-modules-extras/blob/devel/system/locale_gen.py#L67)). If the name of the locale differs from the name in `/etc/locale.gen` the test will fail and the locale will be enabled every time. Example:

```
# egrep -i '^en_us.iso.+15$' /etc/locale.gen
en_US.ISO-8859-15 ISO-8859-15
# locale -a | egrep -i '^en_us.iso.+15$'
en_US.iso885915
```
##### Steps To Reproduce:

Run the following playbook multiple times:

```

---
- hosts: all
  vars:
    locales:
      - "en_US"
      - "en_US.ISO-8859-15"
  tasks:
  - locale_gen: name="{{ item }}" state=present
    with_items: "{{ locales }}"
```
##### Expected Results:

Both tasks should report "changed" only after the first run, if at all. The following run should report "changed=0" because both locales are already enabled.
##### Actual Results:

While "en_US" only gets enabled once, "en_US.ISO-8859-15" will be enabled every time.



Discussion:

Resolving patch:
diff --git a/system/locale_gen.py b/system/locale_gen.py
--- a/system/locale_gen.py
+++ b/system/locale_gen.py
@@ -37,6 +37,7 @@
 LOCALE_NORMALIZATION = {
     ".utf8": ".UTF-8",
     ".eucjp": ".EUC-JP",
+    ".iso885915": ".ISO-8859-15",
 }
 
 # ===========================================


Test patch:
Repository: ansible/ansible-modules-extras

Issue:
locale_gen fails on Ubuntu fresh install
I installed an Ubuntu Trusty on a server (actually used debootstrat on a Ganeti KVM instance, not sure if this information is releavant). I installed locales package too.

The file /var/lib/locales/supported.d/local does not exist and the plugin is not able to determine that we are on Ubuntu system. I think the best way to determine th file to edit is:
- pass it as a paremeter of locale_gen module
- OR use /etc/lsb-release file
- OR use ansible_distribution variable



Discussion:
Can you explain a bit more ? 
For example, how can it be reproduce, what do you see and what you would want to see ?

Ok, so answering to myself ( after some coffee ), the more interesting question is "where does your kvm image come from", as I am not sure we should work around "breakage" from random hosters. But if the breakage is on the official cloud image, we could just switch on adding the file if it is missing.


Resolving patch:
diff --git a/system/locale_gen.py b/system/locale_gen.py
--- a/system/locale_gen.py
+++ b/system/locale_gen.py
@@ -176,7 +176,7 @@ def main():
     state = module.params['state']
 
     if not os.path.exists("/etc/locale.gen"):
-        if os.path.exists("/var/lib/locales/supported.d/local"):
+        if os.path.exists("/var/lib/locales/supported.d/"):
             # Ubuntu created its own system to manage locales.
             ubuntuMode = True
         else:


Test patch: