prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  replace "hidden service" occurrences
  ## Status
  
  ready for review
  
  ## Description of Changes
  
  Changes Proposed:
  
    - no longer refer to [Onion Services](https://2019.www.torproject.org/docs/onion-services.html.en) as hidden services;
    - there are NO new images I added, it's just text;
    - all changed content here is either just a comment (playbook, or shell script);
    - changelog was kept as is.
  
  ## Testing
  
  I followed the _(slightly outdated)_ [Documentation Guidelines](https://docs.securedrop.org/en/latest/development/documentation_guidelines.html), and all looked fine:
  
  ```
  # make docs
  ```
  
  Gave me the following:
  
  ```
      ...
  
  | copying static files... done
  | copying extra files... done
  | dumping search index in English (code: en) ... done
  | dumping object inventory... done
  | build succeeded.
  +--------------------------------------------------------------------------------
  
  [I 190725 16:16:16 server:296] Serving on http://127.0.0.1:8000
  [I 190725 16:16:16 handlers:62] Start watching changes
  [I 190725 16:16:16 handlers:64] Start detecting changes
  ```
  `make docs-linkcheck` returned an error, but that's not related to the changes made here. `docs-lint` ran just fine.
  
  ## Deployment
  
  Any special considerations for deployment?
  
    - AFAIK, no.
  
  ## Checklist
  
  ### If you made changes to the server application code:
  
  - [ ] Linting (`make lint`) and tests (`make -C securedrop test`) pass in the development container
  
  ### If you made changes to `securedrop-admin`:
  
  - [ ] Linting and tests (`make -C admin test`) pass in the admin development container
  
  ### If you made changes to the system configuration:
  
  - [ ] [Configuration tests](https://docs.securedrop.org/en/latest/development/testing_configuration_tests.html) pass
  
  ### If you made non-trivial code changes:
  
  - [ ] I have written a test plan and validated it for this PR
  
  ### If you made changes to documentation:
  
  - [x] Doc linting (`make docs-lint`) passed locally
  
  
  </issue>
  <code>
  [start of install_files/ansible-base/roles/backup/files/0.3_collect.py]
  1 #!/usr/bin/python2.7
  2 """
  3 
  4 This script should be copied to the App server and ran by the anisble
  5 plabook. When run (as root), it collects all of the necessary information
  6 to backup the 0.3 system and stores it in /tmp/sd-backup-0.3-TIME_STAMP.zip.gpg
  7 
  8 """
  9 
  10 import sys
  11 import os
  12 import io
  13 import zipfile
  14 from datetime import datetime
  15 # Import the application config.py file
  16 sys.path.append("/var/www/securedrop")
  17 import config  # noqa: F403
  18 import gnupg  # noqa: F403
  19 
  20 TOR_SERVICES = "/var/lib/tor/services"
  21 TOR_CONFIG = "/etc/tor/torrc"
  22 
  23 
  24 def collect_config_file(zf):
  25     config_file_path = os.path.join(config.SECUREDROP_ROOT, "config.py")
  26     zf.write(config_file_path)
  27 
  28 
  29 def collect_securedrop_data_root(zf):
  30     # The store and key dirs are shared between both interfaces
  31     for root, dirs, files in os.walk(config.SECUREDROP_DATA_ROOT):
  32         for name in files:
  33             zf.write(os.path.join(root, name))
  34 
  35 
  36 def collect_custom_header_image(zf):
  37     # The custom header image is copied over the deafult `static/i/logo.png`.
  38     zf.write(os.path.join(config.SECUREDROP_ROOT, "static/i/logo.png"))
  39 
  40 
  41 def collect_tor_files(zf):
  42     # All of the tor hidden service private keys are stored in the THS specific
  43     # subdirectory `/var/lib/tor/services` backing up this directory will back
  44     # up all of the THS and ATHS required keys needed to restore all the hidden
  45     # services on that system.
  46     for root, dirs, files in os.walk(TOR_SERVICES):
  47         for name in files:
  48             zf.write(os.path.join(root, name))
  49 
  50     # The tor config file has the ATHS client names required to restore
  51     # the ATHS info. These names are also in the the specific client_key file
  52     # but backing up this file makes it easier than parsing the files during a
  53     # restore.
  54     zf.write(TOR_CONFIG)
  55 
  56 
  57 def encrypt_zip_file(zf_fn):
  58     # Encrypt the backup zip file with the application's gpg public key
  59     gpg = gnupg.GPG(binary='gpg2', homedir=config.GPG_KEY_DIR)
  60     e_fn = '{}.gpg'.format(zf_fn)
  61 
  62     stream = io.open(zf_fn, "rb")
  63     gpg.encrypt_file(stream, config.JOURNALIST_KEY, always_trust='True',
  64                      output=e_fn)
  65 
  66 
  67 def main():
  68     # name append a timestamp to the sd-backup zip filename
  69     dt = str(datetime.utcnow().strftime("%Y-%m-%d--%H-%M-%S"))
  70     zf_fn = 'sd-backup-{}.zip'.format(dt)
  71     with zipfile.ZipFile(zf_fn, 'w') as zf:
  72         collect_config_file(zf)
  73         collect_securedrop_data_root(zf)
  74         collect_custom_header_image(zf)
  75         collect_tor_files(zf)
  76     encrypt_zip_file(zf_fn)
  77     print(zf_fn)
  78 
  79 
  80 if __name__ == "__main__":
  81     main()
  82
  [end of install_files/ansible-base/roles/backup/files/0.3_collect.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/install_files/ansible-base/roles/backup/files/0.3_collect.py b/install_files/ansible-base/roles/backup/files/0.3_collect.py
  --- a/install_files/ansible-base/roles/backup/files/0.3_collect.py
  +++ b/install_files/ansible-base/roles/backup/files/0.3_collect.py
  @@ -39,7 +39,7 @@
   
   
   def collect_tor_files(zf):
  -    # All of the tor hidden service private keys are stored in the THS specific
  +    # All of the tor Onion Service private keys are stored in the THS specific
       # subdirectory `/var/lib/tor/services` backing up this directory will back
       # up all of the THS and ATHS required keys needed to restore all the hidden
       # services on that system.
  
verification_info: {"golden_diff": "diff --git a/install_files/ansible-base/roles/backup/files/0.3_collect.py b/install_files/ansible-base/roles/backup/files/0.3_collect.py\n--- a/install_files/ansible-base/roles/backup/files/0.3_collect.py\n+++ b/install_files/ansible-base/roles/backup/files/0.3_collect.py\n@@ -39,7 +39,7 @@\n \n \n def collect_tor_files(zf):\n-    # All of the tor hidden service private keys are stored in the THS specific\n+    # All of the tor Onion Service private keys are stored in the THS specific\n     # subdirectory `/var/lib/tor/services` backing up this directory will back\n     # up all of the THS and ATHS required keys needed to restore all the hidden\n     # services on that system.\n", "issue": "replace \"hidden service\" occurrences\n## Status\r\n\r\nready for review\r\n\r\n## Description of Changes\r\n\r\nChanges Proposed:\r\n\r\n  - no longer refer to [Onion Services](https://2019.www.torproject.org/docs/onion-services.html.en) as hidden services;\r\n  - there are NO new images I added, it's just text;\r\n  - all changed content here is either just a comment (playbook, or shell script);\r\n  - changelog was kept as is.\r\n\r\n## Testing\r\n\r\nI followed the _(slightly outdated)_ [Documentation Guidelines](https://docs.securedrop.org/en/latest/development/documentation_guidelines.html), and all looked fine:\r\n\r\n```\r\n# make docs\r\n```\r\n\r\nGave me the following:\r\n\r\n```\r\n    ...\r\n\r\n| copying static files... done\r\n| copying extra files... done\r\n| dumping search index in English (code: en) ... done\r\n| dumping object inventory... done\r\n| build succeeded.\r\n+--------------------------------------------------------------------------------\r\n\r\n[I 190725 16:16:16 server:296] Serving on http://127.0.0.1:8000\r\n[I 190725 16:16:16 handlers:62] Start watching changes\r\n[I 190725 16:16:16 handlers:64] Start detecting changes\r\n```\r\n`make docs-linkcheck` returned an error, but that's not related to the changes made here. `docs-lint` ran just fine.\r\n\r\n## Deployment\r\n\r\nAny special considerations for deployment?\r\n\r\n  - AFAIK, no.\r\n\r\n## Checklist\r\n\r\n### If you made changes to the server application code:\r\n\r\n- [ ] Linting (`make lint`) and tests (`make -C securedrop test`) pass in the development container\r\n\r\n### If you made changes to `securedrop-admin`:\r\n\r\n- [ ] Linting and tests (`make -C admin test`) pass in the admin development container\r\n\r\n### If you made changes to the system configuration:\r\n\r\n- [ ] [Configuration tests](https://docs.securedrop.org/en/latest/development/testing_configuration_tests.html) pass\r\n\r\n### If you made non-trivial code changes:\r\n\r\n- [ ] I have written a test plan and validated it for this PR\r\n\r\n### If you made changes to documentation:\r\n\r\n- [x] Doc linting (`make docs-lint`) passed locally\r\n\n", "before_files": [{"content": "#!/usr/bin/python2.7\n\"\"\"\n\nThis script should be copied to the App server and ran by the anisble\nplabook. When run (as root), it collects all of the necessary information\nto backup the 0.3 system and stores it in /tmp/sd-backup-0.3-TIME_STAMP.zip.gpg\n\n\"\"\"\n\nimport sys\nimport os\nimport io\nimport zipfile\nfrom datetime import datetime\n# Import the application config.py file\nsys.path.append(\"/var/www/securedrop\")\nimport config  # noqa: F403\nimport gnupg  # noqa: F403\n\nTOR_SERVICES = \"/var/lib/tor/services\"\nTOR_CONFIG = \"/etc/tor/torrc\"\n\n\ndef collect_config_file(zf):\n    config_file_path = os.path.join(config.SECUREDROP_ROOT, \"config.py\")\n    zf.write(config_file_path)\n\n\ndef collect_securedrop_data_root(zf):\n    # The store and key dirs are shared between both interfaces\n    for root, dirs, files in os.walk(config.SECUREDROP_DATA_ROOT):\n        for name in files:\n            zf.write(os.path.join(root, name))\n\n\ndef collect_custom_header_image(zf):\n    # The custom header image is copied over the deafult `static/i/logo.png`.\n    zf.write(os.path.join(config.SECUREDROP_ROOT, \"static/i/logo.png\"))\n\n\ndef collect_tor_files(zf):\n    # All of the tor hidden service private keys are stored in the THS specific\n    # subdirectory `/var/lib/tor/services` backing up this directory will back\n    # up all of the THS and ATHS required keys needed to restore all the hidden\n    # services on that system.\n    for root, dirs, files in os.walk(TOR_SERVICES):\n        for name in files:\n            zf.write(os.path.join(root, name))\n\n    # The tor config file has the ATHS client names required to restore\n    # the ATHS info. These names are also in the the specific client_key file\n    # but backing up this file makes it easier than parsing the files during a\n    # restore.\n    zf.write(TOR_CONFIG)\n\n\ndef encrypt_zip_file(zf_fn):\n    # Encrypt the backup zip file with the application's gpg public key\n    gpg = gnupg.GPG(binary='gpg2', homedir=config.GPG_KEY_DIR)\n    e_fn = '{}.gpg'.format(zf_fn)\n\n    stream = io.open(zf_fn, \"rb\")\n    gpg.encrypt_file(stream, config.JOURNALIST_KEY, always_trust='True',\n                     output=e_fn)\n\n\ndef main():\n    # name append a timestamp to the sd-backup zip filename\n    dt = str(datetime.utcnow().strftime(\"%Y-%m-%d--%H-%M-%S\"))\n    zf_fn = 'sd-backup-{}.zip'.format(dt)\n    with zipfile.ZipFile(zf_fn, 'w') as zf:\n        collect_config_file(zf)\n        collect_securedrop_data_root(zf)\n        collect_custom_header_image(zf)\n        collect_tor_files(zf)\n    encrypt_zip_file(zf_fn)\n    print(zf_fn)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "install_files/ansible-base/roles/backup/files/0.3_collect.py"}]}