python – Django StreamingHttpResponse() is causing server to stop working

I am trying to implement StreamingHttpResponse but came across a tedious issue. The connection appears to be established then after around 2 page requests the webserver stops responding. I am truly bewildered about what is causing this issue. If it was associated with an infinite loop, the time.sleep() method should have prevented the server from overloading. I’d appreciate any help, thanks!

views.py:

    def event_stream():
    initial_data = ""
    while True:
        data = json.dumps(list(Notification.objects.filter(to_user=1).order_by("-created_date").values("info",
        "return_url",
        "from_user","to_user","created_date")),
        cls=DjangoJSONEncoder)

        if not initial_data == data:
            yield "ndata: {}nn".format(data)
            initial_data = data
        time.sleep(1)




class PostStreamView(View):

    def get(self, request):
        response = StreamingHttpResponse(event_stream())
        response('Content-Type') = 'text/event-stream'
        return response

base.html

var eventSource  = new EventSource("{% url 'stream' %}");

eventSource.onopen = function() {
    console.log('We have open connection!');
  }

  eventSource.onmessage = function(e) {
    console.log(e)
  }

  eventSource.onerror = function(e) {
    console.log(`error ${e}`);
  }
</script>

Server Log:

2020-10-20 19:25:51 Tue Oct 20 19:25:51 2020 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /AP%20Psychology/ (ip 10.0.0.124) !!!
2020-10-20 19:25:51 Tue Oct 20 19:25:51 2020 - uwsgi_response_writev_headers_and_body_do(): Broken pipe (core/writer.c line 306) during GET /AP%20Psychology/ (10.0.0.124)
2020-10-20 19:27:33 Tue Oct 20 19:27:33 2020 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /post/12/ (ip 10.0.0.124) !!!
2020-10-20 19:27:33 Tue Oct 20 19:27:33 2020 - uwsgi_response_writev_headers_and_body_do(): Broken pipe (core/writer.c line 306) during GET /post/12/ (10.0.0.124)

My hosting provider is PythonAnywhere

command line – Termux (Terminal) tsu is adding “(unreachable)” to my current working path

When I run tsu (which is Termux’s version of su), my current working directory gets prefixed with “(unreachable)”, as you can see from the transcript of my session.

(u0_a116 …/~)$ tsu
(root …/home)# pwd
(unreachable)/data/data/com.termux/files/home
(root …/home)#

I did some digging and found what seems to me is the culprit.
tsu is a script that sets up an environment for the root user and then runs su to give you root privilege with the new environment. This is what the command that tsu is running looks like after opening all the variables.
/sbin/su -c PATH=/sbin/.magisk/busybox env -i PATH=/data/data/com.termux/files/usr/bin:/data /data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin ANDROID_DATA=/data TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp PREFIX=/ data/data/com.termux/files/usr TERM=xterm-256color LD_PRELOAD=/data/data/com.ter mux/files/usr/lib/libtermux-exec.so ANDROID_ROOT=/system HOME=/data/data/com.ter mux/files/home/.suroot /data/data/com.termux/files/usr/bin/bash

This causes a problem when I try to run a script that is using relative paths. (I’m running a script to setup a full linux distro with proot in Termux).

If I take out the ‘env -i` from the command then I get the current working directory without the prefixed “(unreachable)”. This does not setup the new environment, it leaves the old environment intact as if I would have selected –preserve option.

networking – SOCKS proxy via OpenSSH on Windows 10 not connecting (but working on MacOS with similar config)

In the attached image I have established an SSH tunnel that should allow me to resolve network requests through the remote (in this case a virtual machine containing Ubuntu).

However I am unable to resolve URLs when connected to the proxy.

enter image description here

When replicating this exact same scenario on my MacOS laptop, the laptop is able to resolve URLs through the VM. The MacBook is a physically separate device but connected to the same local network, with network access to the VM.

applications – I’m facing issue in Android studios, my emulator process isn’t working

My codings are correct it’s just as soon as I run my app it finishes gradle build but after that message pops up showing error while waiting for device:the emulator process for avd was killed

I intalled latest version already made new app in avd so that it can create but it isn’t happening do you have any solutions?

Windows Touchscreen drivers not working properly

I’m currently using Windows 10 on a tablet/PC, the touch screen feature used to work flawlessly on the original install of Windows 10 which came with the device. But after I tried to install Ubuntu I couldn’t login on Windows anymore and had to make a fresh install, but now the driver doesn’t work properly anymore with the screen touch commands mirrored, apparently divided in half and the cursor moving on the opposite direction of my finger. I tried to install the drivers from the Windows update catalogue and the ones made available by the manufacturer, but the screen behave even more strangely or no change was perceived. I think the device is a Silead Touch L2c.

  • Is there a way to check the device (Touchscreen) model on my machine?
  • What is the correct way to install a driver having the *.sys and *.fw files.
  • Can You think of any possible solution? The manufacturer offered to collect my device for technical assistance, but I can’t allow being without my device at the moment.

20.04 – Calibre No Longer Working

Calibre stopped working recently. Tried uninstalling and reinstalling.

When I open a terminal and call $calibre I get the following error message:

Traceback (most recent call last):
  File "/usr/bin/calibre", line 20, in <module>
    sys.exit(calibre())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 73, in calibre
    main(args)
  File "/usr/lib/calibre/calibre/gui2/main.py", line 543, in main
    listener = create_listener()
  File "/usr/lib/calibre/calibre/gui2/main.py", line 514, in create_listener
    return Listener(address=gui_socket_address())
  File "/usr/lib/calibre/calibre/utils/ipc/server.py", line 110, in __init__
    self._listener._unlink.cancel()
AttributeError: 'NoneType' object has no attribute 'cancel'

Do I need to install some dependency that the sudo apt install didn’t get? I tried installing via command line and the software installer/updater GUI.

I’m on version Ubuntu 20.04.1 LTS. I made sure that my software in general is up to date also.

mediatek – Fastboot not working with new Teclast P80H

I am developing an in-car product and app. Previously, I had a Teclast P80H tablet with a micro-USB connector and running Android 7.0. I was able to enter fastboot mode and from Windows cmd window, issue the Android SDK command “fastboot oem off-mode-charge 0”. This successfully reconfigured that older tablet so that, if the tablet was fully shut down and turned off, connecting 5V to the micro-USB jack would cause the tablet to boot up and run. This was great for my in-car product and app.

Now that old tablet is no longer available, so I’m trying a newer version of the Teclast P80H. This one has a USB-C connector and runs Android 10.0. It takes a slightly different method to get into fastboot mode, but I think I’ve figured it out. However, when I issue the command “fastboot oem off-mode-charge 0” I get a message “FAILED (remote: ‘unknown cmd.’)”.

In order to make sure I really do have the tablet in fastboot mode, I’ve tried a couple things. First, issuing “fastboot reboot” does indeed reboot the new tablet like it did with the old tablet. Even better, the command “fastboot oem get_identifier_token” seems to work, telling me “(bootloader) Identifier token:” and on the next line “(bootloader) ******************”. Well, I’ve omitted the actual identifier for security purposes, of course, I guess. But this seems to prove to me that I have the tablet in the right mode to receive the “fastboot oem off-mode-charge 0” command.

But it seems like maybe this version of the tablet’s oem commands doesn’t include “off-mode-charge”. Perhaps the name or syntax has changed. But I don’t know how to find out. While “fastboot help” works, it seems that ‘fastboot oem help” doesn’t. I don’t know how to figure out how to configure this new tablet.

Again, my objective is for the tablet to boot up from full shutdown, whenever 5V is applied through the USB-C connector. BTW, I’m using the USB-C to USB-A cable that came with the tablet, plugging the USB-A end into my Windows 10 computer.

I did re-install the latest Android Studio. I also updated the SDK to Android 10. (It was Android 9.) However, the fastboot.exe program remains with an 11/14/2019 file date, perhaps the original date I installed it.

Any suggestions? Thanks!

sharepoint online – SPFX Source URL Redirect NOT Working

I am currently working on a custom WebPart in SPFX and am having some issues with a URL redirect.

The code is looking to see if a field is empty, if the field == empty then it will automatically redirect to the current page. If the field is NOT empty, the code will redirect to the URL provided in the field.

Here is the code:

var tableResults="";
      var response = request.currentTarget.response || request.target.responseText;
      var data = JSON.parse(response);
      var currentPageUrl = this.context.pageContext.site.serverRequestPath;
      var redirectURL = this.properties.redirect;
      if (data.error) {
          console.log(data.error.message.value);
      }
      else {
          tableResults="<table border='1' cellpadding='10' ><tr><th>Enroll</th><th>Event</th><th>Spots Left</th></tr>";
          for (var i=0; i<data.d.results.length; i++)
          {
              //alert(i + ": " + data.d.results(i).Time);
              if(parseInt(data.d.results(i).AttendeesId) < parseInt(data.d.results(i).Quota) && redirectURL == "")
              {
                tableResults=tableResults + "<tr><td><a href='https://ewscripps.sharepoint.com/sites/rsvp/Lists/Register/NewForm.aspx?SessionID="+ data.d.results(i).Id + "&Source=" + currentPageUrl + "'>Click To Enroll</a></td>";
              }
              else if (parseInt(data.d.results(i).AttendeesId) < parseInt(data.d.results(i).Quota) && redirectURL != "")
              {
                console.log(redirectURL);
                tableResults=tableResults + "<tr><td><a href='https://ewscripps.sharepoint.com/sites/rsvp/Lists/Register/NewForm.aspx?SessionID="+ data.d.results(i).Id + "&Source=" + redirectURL + "'>Click To Enroll</a></td>";
              }
              else
              {
                tableResults=tableResults + "<tr><td><font color='red'>Event Full</font></td>";
              }
              var spotsLeft = data.d.results(i).Quota - data.d.results(i).AttendeesId;
              tableResults=tableResults + "<td>" + data.d.results(i).Title + "</td><td>" + spotsLeft + "</td></tr>";
          }
          tableResults=tableResults + "</table>";

            //then you just need to generate the legend
            sessionsdiv.innerHTML= tableResults;
      }

The console.log(redirectURL) is showing the URL entered in the field, but for some reason, SharePoint is redirecting to the “All Items” list as it does by default.

Any help would be much appreciated!

Thanks!

unity – Scene reset function not working

I am entirely new to programming. Recently just watched the Youtube tutorial https://www.youtube.com/watch?v=OR0e-1UBEOU&t=4826 and follow the way the author wrote the code until (1:22:24). I’m not sure why the scene reset function for trasnform.position.y > 10 not working for me. The compiler does not detect any error and game run as normal but the scene does not reset when the bird position on y axis more than 10. I’m using another bird object anwyay since i can’t find exactly the same bird picture as author did. Also is there a way to check what the value store in each variable? Example I want to check what the value stored in “transform.position.y” to find out why it is not working.

using UnityEngine;

using UnityEngine.SceneManagement;

public class GreenBird : MonoBehaviour
{
Vector3 _initialPosition;

private void Awake()
{

    _initialPosition = transform.position;
}

void update()
{
    if (transform.position.y > 10)
    {
        string currentSceneName = SceneManager.GetActiveScene().name;
        SceneManager.LoadScene(currentSceneName);
    }
}

private void OnMouseDown()
{
    GetComponent<SpriteRenderer>().color = Color.red;


}



private void OnMouseUp()
{
    GetComponent<SpriteRenderer>().color = Color.white;
    Vector2 directionToInitialPosition = _initialPosition - transform.position;
    GetComponent<Rigidbody2D>().AddForce(directionToInitialPosition * 100);


}

private void OnMouseDrag()
{
    Vector3 newPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    transform.position = new Vector3(newPosition.x, newPosition.y);
}

}

SharePoint PWA Manifest file not working

I have created an SPfx webpart with PWA features. My service worker and manifest.json file are working in my local workbench but when deployed to sharepoint 2019 server, manifest file does not load.

I tried to change the extension to manifest.webmanifest but it is still not working.
Also added crossorigin=”use-credentials” programatically as below –

aLink.setAttribute(“crossOrigin”,”use-credentials”);

My manifest file is read from SharePoint style library. Is there anything else that is missing to make it work?