Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dprint not available in Package Control #4

Open
dalisoft opened this issue Jan 3, 2021 · 10 comments
Open

dprint not available in Package Control #4

dalisoft opened this issue Jan 3, 2021 · 10 comments

Comments

@dalisoft
Copy link

dalisoft commented Jan 3, 2021

Hi @dsherret

I tried install package via Package control and it did not found, so i looked at here and seems error 404, can you look please if you can find time?

@dsherret dsherret added the help wanted Extra attention is needed label Jan 3, 2021
@dsherret
Copy link
Member

dsherret commented Jan 3, 2021

Sorry, I never actually ended up getting this on package control. There were some outstanding issues:

wbond/package_control_channel#7969 (comment)

@dalisoft
Copy link
Author

dalisoft commented Jan 3, 2021

@dsherret Thanks for quick reply and link. Seems currently solution is installing via git.

Steps:

  1. Open Sublime Text
  2. Cmd/Ctrl + Shift + P
  3. Browse Packages
  4. Open terminal in directory
  5. Clone this repository to that directory

It works for me and should work for everyone.

Have a nice day!
Happy new year!

Regards,
Davlik

@dalisoft dalisoft closed this as completed Jan 3, 2021
@KyGost
Copy link

KyGost commented May 12, 2021

@dalisoft did the package end up actually working? Upon installing no commands seem to become available for me.

@dsherret dsherret reopened this May 12, 2021
@imjordanxd
Copy link

Anyone manage to get this working?

@rope-hmg
Copy link
Contributor

rope-hmg commented Feb 4, 2022

When cloning to the Packages directory and restarting sublime I see the following error in the sublime console:

Sublime Version: Dev Channel, Build 4114
reloading python 3.3 plugin dprint-sublime.dprint
Traceback (most recent call last):
  File "/Applications/Sublime Text (4109).app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/Users/username/Library/Application Support/Sublime Text 3/Packages/dprint-sublime/dprint.py", line 8, in <module>
    dprint_exec = DprintExec()
NameError: name 'DprintExec' is not defined

I'm not familiar with the sublime plugin api, so this doesn't really mean anything to me.

Thanks

@rope-hmg
Copy link
Contributor

rope-hmg commented Feb 4, 2022

So I've done some investigating and it looks like there are a few problems.

json_text = subprocess.check_output(["dprint", "editor-info"], cwd=dir_path, shell=True).decode("utf8")

If I change "dprint", "editor-info" to "dprint editor-info" then it work, but it complains about the schema version. The plugin lists it as 1, but the editor-info is coming back with 4.

If I change that to 4 then I can format, but it writes the dprint help text to the buffer.

The issue is again with the array arguments in

p = Popen(["dprint", "stdin-fmt", "--file-name", os.path.basename(file_path)],
			stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=dir_path, shell=True)

If I merge them again I dprint complains with error: Found argument 'stdin-fmt' which wasn't expected, or isn't valid in this context

@rope-hmg
Copy link
Contributor

rope-hmg commented Feb 4, 2022

One other thing I forgot.

I had to move the line

dprint_exec = DprintExec()

to the bottom of the file.

@rope-hmg
Copy link
Contributor

rope-hmg commented Feb 4, 2022

Update:

Removed shell=True from the commands:

json_text = subprocess.check_output(["dprint", "editor-info"], cwd=dir_path).decode("utf8")

Also looked at dprint src to find out why fmt-stdin wasn't working.

p = Popen(["dprint", "fmt", "stdin", os.path.basename(file_path)],
			stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=dir_path)

I've reached the point where the problem is with:

print("#----------", file_text)
stdout, stderr = p.communicate(bytes(file_text, "utf8"))
print("#----------", stdout)

file_text looks correct, but stdout is just b'Formatted \x1b[1m1\x1b[0m file.\n'

@rope-hmg
Copy link
Contributor

rope-hmg commented Feb 4, 2022

So. Turns out I misread the code. Should have been --stdin in Popen. It's working fine now. I'll make a PR.

@dsherret
Copy link
Member

Thanks for the help @rope-hmg! I opened wbond/package_control_channel#8509

@dsherret dsherret removed the help wanted Extra attention is needed label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants