Skip to content

Commit

Permalink
refs #7 : add - error notification when proper language is not chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
inureyes committed Jan 13, 2017
1 parent 6a233df commit 123b368
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ATOM package to run code snippets via Sorna Cloud API server (https://cloud.sorn
Description
===========

`sorna-code-runner` is ATOM editor package to add remote code execution feature using [Sorna Cloud API Service](https://cloud.sorna.io). `sorna-code-runner` uses [Sorna Opensource framework](http://sorna.io) and [Sorna API](http://docs.sorna.io)). Currently, Sorna supports 11 programming languages now.
`sorna-code-runner` is ATOM editor package to add remote code execution feature using [Sorna Cloud API Service](https://cloud.sorna.io). `sorna-code-runner` uses [Sorna framework](http://sorna.io) and [Sorna API](http://docs.sorna.io)). Currently, Sorna supports 11 programming languages now.

You can run your code (or code snippet) without installing or setting any programming environment with this package. All you need to run code is

Expand Down
12 changes: 6 additions & 6 deletions lib/sorna-code-runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ module.exports = SornaCodeRunner =
realActivate: (state) ->
@SornaCodeRunnerView = new SornaCodeRunnerView(state.SornaCodeRunnerViewState, @)
@resultPanel = atom.workspace.addBottomPanel(item: @SornaCodeRunnerView.getElement(), visible: false)
console.log('Current access key: '+ @getAccessKey())

# Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
@subscriptions = new CompositeDisposable
Expand All @@ -47,7 +46,6 @@ module.exports = SornaCodeRunner =
# Register command
@subscriptions.add atom.commands.add 'atom-text-editor',
'sorna-code-runner:run': => @runcode()
console.log "loaded"

serialize: ->
SornaCodeRunnerViewState: @SornaCodeRunnerView.serialize()
Expand Down Expand Up @@ -157,7 +155,6 @@ module.exports = SornaCodeRunner =
requestInfo = @newRequest('DELETE', '/v1/kernel/'+kernelId, null)
return fetch(@baseURL + '/v1/kernel/'+kernelId, requestInfo)
.then( (response) ->
console.log(response)
if response.ok is false
if response.status isnt 404
errorMsg = "sorna-code-runner: destroy failed - " + response.statusText
Expand All @@ -177,7 +174,6 @@ module.exports = SornaCodeRunner =
requestInfo = @newRequest('PATCH', '/v1/kernel/'+@kernelId, null)
fetch(@baseURL + '/v1/kernel/'+@kernelId, requestInfo)
.then( (response) ->
console.log(response)
if response.ok is false
errorMsg = "sorna-code-runner: " + response.statusText
notification = atom.notifications.addError errorMsg,
Expand Down Expand Up @@ -238,12 +234,17 @@ module.exports = SornaCodeRunner =
when "php" then kernelName = "php7"
when "haskell" then kernelName = "haskell"
when "nodejs", "javascript" then kernelName = "nodejs4"
else kernelName = "python3"
else kernelName = null
console.log "Kernel Language: "+ kernelName
return kernelName

sendCode: ->
kernelType = @chooseKernelType()
if kernelType is null
errorMsg = "sorna-code-runner: language is not specified by Atom."
notification = atom.notifications.addError errorMsg, dismissable: true,
description: 'Check the grammar indicator at bottom bar and make sure that it is correctly recoginzed (NOT `Plain Text`).\nTry one of the followings:\n * Save current editor with proper file extension.\n * Install extra lauguage support package. (e.g. `language-r`, `language-haskell`)'
return false
if kernelType isnt @kernelType or @kernelId is null
if @kernelId isnt null
destroyAndCreateAndRun = @destroyKernel(@kernelId)
Expand Down Expand Up @@ -277,7 +278,6 @@ module.exports = SornaCodeRunner =
requestInfo = @newRequest('POST', '/v1/kernel/'+ @kernelId, requestBody)
fetch(@baseURL + '/v1/kernel/' + @kernelId, requestInfo)
.then( (response) =>
console.debug response
if response.ok is false
errorMsg = "sorna-code-runner: " + response.statusText
notification = atom.notifications.addError errorMsg, dismissable: false
Expand Down

0 comments on commit 123b368

Please sign in to comment.